# The definition of the hamiltonian in lagrangian mechanics

So going through the "Analytical Mechanics by Hand and Finch". In section 1.10 of the book, the Hamiltonian $H$ is defined as: $$H = \sum_k{\dot{q_k}\frac{\partial L}{\partial \dot{q_k}} -L}.\tag{1.65}$$

And then author affirms that this quantity is constant and takes the derivative $\frac{dH}{dt}$: $$\frac{dH}{dt} = \sum_k {\ddot{q_k} \frac{\partial L}{\partial \dot{q_k}} + \dot{q_k}\frac{d}{dt}(\frac{\partial L}{\partial \dot{q_k}}) - \frac{d L}{d t}}.\tag{1.66}$$

Now the book writes: "According to the chain rule for differentiating an implicit function over time": $$\frac{dL}{dt} = \sum_k {\frac{\partial L}{\partial q_k}\dot{q_k} + \sum{}\frac{\partial L}{\partial \dot{q_k}}{\ddot{q_k}} + \frac{\partial L}{\partial t}}.\tag{1.67}$$

And the summing the second and third gives: $$\frac{dH}{dt} = - \frac{\partial L}{\partial t}.\tag{1.68}$$ Now I don't understand how the third equation is derived and also why is the Hamiltonian $H$ is defined in the way it is in the first equation?

The Hamiltonian is constant if the Lagrangian has no explicit dependence on time. I think you are getting confused by the difference between $\partial L / \partial t$ and $d L / dt$. The quantity $dL / dt$ is a total derivative, encoding all time dependence of $L$. If the Lagrangian is assumed to be a function of coordinates $q_i$, velocities $\dot{q_i}$ and time $t$, we have $$\frac{dL}{dt} = \sum_i \left( \frac{\partial L}{\partial q_i} \frac{dq_i}{dt} + \frac{\partial L}{\partial \dot{q}_i} \frac{d\dot{q}_i}{dt} \right) + \frac{\partial L}{\partial t}$$ The last term is the partial derivative of $L$ with respect to time, so it only encodes the explicit dependence of $L$ on time. For instance if $L = \frac{1}{2} m \dot{q}^2 - eE(q)\sin(\omega t)$, $\frac{\partial L}{\partial t} = -eE(q) \cos(\omega t)$.

Therefore, if the Hamiltonian $H$ is defined as $$H = \sum_i \left( \dot{q}_i \frac{\partial L}{\partial \dot{q}_i} \right) - L$$ we have that the total derivative $dH / dt$ is given by $$\frac{dH}{dt} = \sum_i \left( \frac{\partial L}{\partial q_i} \frac{dq_i}{dt} + \frac{\partial L}{\partial \dot{q}_i} \frac{d\dot{q}_i}{dt} \right) - \frac{dL}{dt}$$ so substituting in our expression for $dL / dt$ gives $$\frac{dH}{dt} = -\frac{\partial L}{\partial t}.$$ Therefore, if the Lagrangian has no explicit time dependence, the Hamiltonian is constant. For example if $L = \frac{1}{2} m \dot{q}^2 - V(q)$, $\partial L / \partial t = 0$ and the hamiltonian $\frac{1}{2} m \dot{q}^2 + V(q)$ is constant.

• Yes, you're right. My confusion was indeed due to the difference between the partial derivative and the total derivative. – daljit97 Aug 25 '18 at 19:32

The first equation is the definition of the Hamiltonian. This definition is an application of the Legendre transformation, which converts a function of one variable to a function of another in a particular way to preserve the information contained in the first, but might allow a more practical or useful calculation scheme. It's beyond the scope of this answer to go into the details. The Wikipedia page on the Legendre transform is not a particularly good introduction to the topic.

The third equation is not derived, it's simply an expression of the derivative. A mathematical application of the chain rule to $L(q,\dot{q},t)$.

1. Ref. 1 is confusingly calling the Lagrangian energy function $H(q,\dot{q},t)$ for the Hamiltonian. We stress that the whole Section 1.10 is purely within the Lagrangian formalism. Eq. (1.68) follows after time differentiation of the definition (1.65) and use of Lagrange equations (1.60).

2. In contrast, the function that is usually called the Hamiltonian $H(q,p,t)$ takes the same value but depends on momentum $p$ rather than velocity $\dot{q}$. The Hamiltonian formalism and the Legendre transformation are first explained in Sections 5.3-4.

References:

1. L.N. Hand & J.D. Finch, Analytical Mechanics, 1998; Section 1.10.

In your first equation, the Hamiltonian is defined in terms of the Lagrangian via an operation called a Legendre transformation. They are most commonly seen in thermodynamics and classical mechanics, and are used to convert functions of one variable into functions of another variable without disturbing the physics. Several thermodynamic variables are obtained using this procedure; for example, the Helmholtz free energy $A(T,V,N)$ is obtained by transforming the internal energy $U(S,V,N)$ by the Legendre transformation $A=U-TS$. Likewise, the Gibbs free energy $G(T,P,N)$ is obtained from the enthalpy $H(S,P,N)$ by the Legendre transformation $G=H-TS$. (The enthalpy is obtained from the internal energy using a non-standard Legendre transformation $H=U+PV$.)

In this case, we wish to switch the set of variables from $\{q_i,\dot{q}_i\}$ to $\{q_i,p_i\}$, and so we use the Legendre transformation to create the Hamiltonian $H(\{q_i,p_i\})$ from the Lagrangian $L(\{q_i,\dot{q}_i\})$ via the Legendre transformation in your question.