Skip to main content
Physics LibreTexts

2.3: Hamiltonian Function and Energy

  • Page ID
    34747
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    The canonical form (19) of the Lagrange equation has been derived using Eq. (18), which is formally similar to Eq. (1.22) for a potential force. Does this mean that the system described by Eq. (19) always conserves energy? Not necessarily, because the "potential energy" \(U\) that participates in Eq. (18), may depend not only on the generalized coordinates but on time as well. Let us start the analysis of this issue with the introduction of two new (and very important!) notions: the generalized momentum corresponding to each generalized coordinate \(q_{j}\),

    \[p_{j} \equiv \frac{\partial L}{\partial \dot{q}_{j}},\] and the Hamiltonian function 12 \[H \equiv \sum_{j} \frac{\partial L}{\partial \dot{q}_{j}} \dot{q}_{j}-L \equiv \sum_{j} p_{j} \dot{q}_{j}-L .\] To see whether the Hamiltonian function is conserved during the motion, let us differentiate both sides of its definition (32) over time: \[\frac{d H}{d t}=\sum_{j}\left[\frac{d}{d t}\left(\frac{\partial L}{\partial \dot{q}_{j}}\right) \dot{q}_{j}+\frac{\partial L}{\partial \dot{q}_{j}} \ddot{q}_{j}\right]-\frac{d L}{d t} .\] If we want to make use of the Lagrange equation (19), the last derivative has to be calculated considering \(L\) as a function of independent arguments \(q_{j}, \dot{q}_{j}\), and \(t\), so that \[\frac{d L}{d t}=\sum_{j}\left(\frac{\partial L}{\partial q_{j}} \dot{q}_{j}+\frac{\partial L}{\partial \dot{q}_{j}} \ddot{q}_{j}\right)+\frac{\partial L}{\partial t},\] where the last term is the derivative of \(L\) as an explicit function of time. We see that the last term in the square brackets of Eq. (33) immediately cancels with the last term in the parentheses of Eq. (34). Moreover, using the Lagrange equation (19a) for the first term in the square brackets of Eq. (33), we see that it cancels with the first term in the parentheses of Eq. (34). As a result, we arrive at a very simple and important result: \[\frac{d H}{d t}=-\frac{\partial L}{\partial t} .\] The most important corollary of this formula is that if the Lagrangian function does not depend on time explicitly \((\partial L / \partial t=0)\), the Hamiltonian function is an integral of motion: \[H=\text { const. }\] Let us see how this works, using the first two examples discussed in the previous section. For a 1D particle, the definition (31) of the generalized momentum yields \[p_{x} \equiv \frac{\partial L}{\partial v}=m v,\] so that it coincides with the usual linear momentum - or rather with its \(x\)-component. According to Eq. (32), the Hamiltonian function for this case (with just one degree of freedom) is \[H \equiv p_{x} v-L=p_{x} \frac{p_{x}}{m}-\left(\frac{m}{2} \dot{x}^{2}-U\right)=\frac{p_{x}^{2}}{2 m}+U,\] i.e. coincides with particle’s mechanical energy \(E=T+U\). Since the Lagrangian does not depend on time explicitly, both \(H\) and \(E\) are conserved.

    However, it is not always that simple! Indeed, let us return again to our testbed problem (Figure 1). In this case, the generalized momentum corresponding to the generalized coordinate \(\theta\) is \[p_{\theta} \equiv \frac{\partial L}{\partial \dot{\theta}}=m R^{2} \dot{\theta},\] and Eq. (32) yields: \[\begin{aligned} H & \equiv p_{\theta} \dot{\theta}-L=m R^{2} \dot{\theta}^{2}-\left[\frac{m}{2} R^{2}\left(\dot{\theta}^{2}+\omega^{2} \sin ^{2} \theta\right)+m g R \cos \theta\right]+\text { const } \\ & \equiv \frac{m}{2} R^{2}\left(\dot{\theta}^{2}-\omega^{2} \sin ^{2} \theta\right)-m g R \cos \theta+\text { const. } \end{aligned}\] This means that (as soon as \(\omega \neq 0\) ), the Hamiltonian function differs from the mechanical energy \[E \equiv T+U=\frac{m}{2} R^{2}\left(\dot{\theta}^{2}+\omega^{2} \sin ^{2} \theta\right)-m g R \cos \theta+\text { const }\] The difference, \(E-H=m R^{2} \omega^{2} \sin ^{2} \theta\) (besides an inconsequential constant), may change at bead’s motion along the ring, so that although \(H\) is an integral of motion (since \(\partial L / \partial t=0\) ), the energy is not conserved.In this context, let us find out when these two functions, \(E\) and \(H\), do coincide. In mathematics, there is a notion of a homogeneous function \(f\left(x_{1}, x_{2}, \ldots\right)\) of degree \(\lambda\), defined in the following way: for an arbitrary constant \(a\), \[f\left(a x_{1}, a x_{2}, \ldots\right)=a^{\lambda} f\left(x_{1}, x_{2}, \ldots\right) .\] Such functions obey the following Euler theorem: 13 \[\sum_{j} \frac{\partial f}{\partial x_{j}} x_{j}=\lambda f \text {, }\] which may be readily proved by differentiating both parts of Eq. (42) over \(a\) and then setting this parameter to the particular value \(a=1\). Now, consider the case when the kinetic energy is a quadratic form of all generalized velocities \(\dot{q}_{j}\) : \[T=\sum_{j, j^{\prime}} t_{j j^{\prime}}\left(q_{1}, q_{2}, \ldots, t\right) \dot{q}_{j} \dot{q}_{j^{\prime}}\] with no other terms. It is evident that such \(T\) satisfies the definition of a homogeneous function of the velocities with \(\lambda=2,{ }^{14}\) so that the Euler theorem (43) gives \[\sum_{j} \frac{\partial T}{\partial \dot{q}_{j}} \dot{q}_{j}=2 T \text {. }\] But since \(U\) is independent of the generalized velocities, \(\partial L / \partial \dot{q}_{j}=\partial T / \partial \dot{q}_{j}\), and the left-hand side of Eq. (45) is exactly the first term in the definition (32) of the Hamiltonian function, so that in this case \[H=2 T-L=2 T-(T-U)=T+U=E .\] So, for a system with a kinetic energy of the type (44), for example, a free particle with \(T\) considered as a function of its Cartesian velocities, \[T=\frac{m}{2}\left(v_{x}^{2}+v_{y}^{2}+v_{z}^{2}\right),\] the notions of the Hamiltonian function and the mechanical energy are identical. Indeed, some textbooks, very regrettably, do not distinguish these notions at all! However, as we have seen from our bead-on-the-rotating-ring example, these variables do not always coincide. For that problem, the kinetic energy, in addition to the term proportional to \(\dot{\theta}^{2}\), has another, velocity-independent term \(-\) see the first of Eqs. (23) - and hence is not a quadratic-homogeneous function of the angular velocity, giving \(E \neq H\).

    Thus, Eq. (36) expresses a new conservation law, generally different from that of mechanical energy conservation.


    \({ }^{12}\) It is named after Sir William Rowan Hamilton, who developed his approach to analytical mechanics in 1833, on the basis of the Lagrangian mechanics. This function is sometimes called just the "Hamiltonian", but it is advisable to use the full term "Hamiltonian function" in classical mechanics, to distinguish it from the Hamiltonian operator used in quantum mechanics. (Their relation will be discussed in Sec. \(10.1\) below.)

    \({ }^{13}\) This is just one of many theorems bearing the name of their author - the genius mathematician Leonhard Euler (1707-1783).

    \({ }^{14}\) Such functions are called quadratic-homogeneous.

    \({ }^{15}\) Such coordinates are frequently called cyclic, because in some cases (like in the second example considered below) they represent periodic coordinates such as angles. However, this terminology is misleading, because some "cyclic" coordinates (e.g., \(x\) in our first example) have nothing to do with rotation.


    This page titled 2.3: Hamiltonian Function and Energy is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Konstantin K. Likharev via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.