# Hamiltonian Mechanics

When describing the mechanical state of a system of particles by specifying $n$ generalized coordinates $q_i$ and $n$ velocities $\dot{q_i}$, one can formulate the laws of mechanics in terms of the Lagrangian and the Euler-Lagrange equations derived from it. However, in the study of certain problems of mechanics, it is advantageous to describe the system in terms of the generalized coordinates $q_i$ and momenta $p_i$ of the system. In this formulation of mechanics, the equations of motion take on a simple, symmetric form, in which they are known as Hamilton's equations, or the canonical form of the Euler-Lagrange equations. We begin our study of Hamiltonian mechanics by deriving Hamilton’s equations in two ways: one of which uses differential calculus; the other involves defining a new action functional corresponding to the {$q_i, p_i, H$} formulation and deriving its associated Euler-Lagrange equations. Then we show that Lagrange's equations and Hamilton's equations are equivalent ways of describing the mechanics of a system, using properties of the Legendre Transformation. We conclude our analysis with a brief discussion of some consequences of the Hamiltonian formulation of mechanics.

## Derivation of Hamilton’s Equations

Let $\ L(q_1,...,q_n, \dot{q_1}, ..., \dot{q_n}, t)$ be the Lagrangian of a system of particles described by $n$ generalized coordinates. The Euler-Lagrange equations of the associated action functional are

$\frac{\partial L}{\partial q_i} = \frac{d}{dt} \left( \frac{\partial L}{\partial \dot{q_i} } \right), \qquad i = 1, ..., n$

This is a system of $n$ second order differential equations. We obtain Hamilton's equations by reducing this system to a system of $2n$ first order differential equations. The generalized momenta are defined by the equations $p_i = \frac{\partial L}{\partial \dot{q_i}}, i = 1,...,n.$ Assume that $\ L$ is a convex function of $\ \dot{q_i}$, i.e. $\det \left[ \frac{\partial^2 L}{\partial \dot{q_i} \, \partial \dot{q_j} } \right] > 0$, where $\ \left[ \frac{\partial^2 L}{\partial \dot{q_i} \, \partial \dot{q_j} } \right]$ denotes the $n$ x $n$ matrix of second order partial derivatives of $\ L$ with respect to $\ \dot{q_i}$. Then the equations used to define $\ p_i$ earlier also define $\ \dot{q_i}$ as functions of $\ t, q_i,$ and $\ p_i$. Define the Hamiltonian $\ H(q_1,..., q_n, p_1,..., p_n, t)$ of the system by the formula

$H = \displaystyle{\sum_{i=1}^n p_i \dot{q_i} } - L$

This is the Legendre Transformation of the Lagrangian, when $\ p_i$ is defined as before. By definition of H,

\begin{align} dH & = \displaystyle{\sum_{i=1}^n p_i d \dot{q_i} } + \displaystyle{\sum_{i=1}^n \dot{q_i} d p_i } - dL \\ & = \displaystyle{\sum_{i=1}^n p_i d \dot{q_i} } + \displaystyle{\sum_{i=1}^n \dot{q_i} d p_i } - \displaystyle{\sum_{i=1}^n \frac{\partial L}{\partial q_i} d q_i } - \displaystyle{\sum_{i=1}^n \frac{\partial L}{\partial \dot{q_i} } d \dot{q_i} } - \frac{\partial L}{\partial t} dt \\ \end{align}

By definition of $p_i$, the first and fourth terms cancel so

$dH = \displaystyle{\sum_{i=1}^n \dot{q_i} d p_i } - \displaystyle{\sum_{i=1}^n \frac{\partial L}{\partial q_i} d q_i } - \frac{\partial L}{\partial t} dt$

Therefore, the following system of first-order differential equations holds:

$\begin{cases} \dot{q_j} = \frac{\partial H}{\partial p_j}, \quad j=1,...,n \\ \dot{p_j} = - \frac{\partial H}{\partial q_j}, \quad j=1,...,n \\ \frac{\partial H}{\partial t} = - \frac{\partial L}{\partial t} \end{cases}$

The first $2n$ equations are known as Hamilton’s equations.

Alternatively, consider the action functional

$I[q_1,...,q_n] = \int_{t_1}^{t_2} L(q_1,..., q_n, \dot{q_1},..., \dot{q_n}, t) dt$.

Define $\ H(q_1,..., q_n, p_1,..., p_n, t)$ as before. Define a new functional

$J[q_1,..., q_n, p_1,..., p_n] = \int_{t_1}^{t_2} \left( \sum_{i=1}^n p_i \dot{q_i} - H(q_1,..., q_n, p_1,..., p_n, t) \right) dt$

where $q_i, p_i$ are $2n$ independent functions. When $\ p_i = \frac{\partial H}{\partial \dot{q_i} } , i = 1,...,n$, we have $\ J[q_1,..., q_n, p_1,..., p_n] = I[q_1,...,q_n]$. (We again assume that $\det \left[ \frac{\partial^2 L}{\partial \dot{q_i} \, \partial \dot{q_j} } \right] > 0$, so we can solve for $\ \dot{q_i}$ as functions of $\ t, q_i,$ and $\ p_i$.) The Euler-Lagrange equations of $\ J[q_1,..., q_n, p_1,..., p_n]$ are

$- \frac{\partial H}{\partial q_i} = \dot{p_i}, \quad - \frac{\partial H}{\partial p_i} + \dot{q_i} = 0$

These are precisely Hamilton’s equations. We conclude that the Euler-Lagrange equations are equivalent to Hamilton’s equations provided that the functionals $\ I$ and $\ J$ have the same extrema.

Reference: Calculus of Variations by I.M. Gelfand & S.V. Fomin (translated and edited by Richard A. Silverman), 1991.

## Equivalence of Euler-Lagrange and Hamiltonian formulations of mechanics

We demonstrate the equivalence of the Euler-Lagrange and Hamiltonian formulations of mechanics by showing that the functionals $\ I$ and $\ J$ , as defined before, have the same extrema. To do this, first observe that the Legendre Transformation is an involution. Thus, defining $\ p_i$ and $\ H(q_1,..., q_n, p_1,..., p_n, t)$ as before, it follows that the Lagrangian $\ L$ is the Legendre transform of $\ H$, since

$dH = - \displaystyle{\sum_{i=1}^n \frac{\partial L}{\partial q_i} d q_i } + \displaystyle{\sum_{i=1}^n \dot{q_i} d p_i } - \frac{\partial L}{\partial t} dt$

so $\frac{\partial H}{\partial p_i} = \dot{q_i}$ for $i = 1,...,n$, and hence

$- H + \displaystyle{\sum_{i=1}^n p_i \frac{\partial H}{\partial p_i} } = L - \displaystyle{\sum_{i=1}^n p_i \dot{q_i} } + \displaystyle{\sum_{i=1}^n p_i \dot{q_i} } = L$.

Next, it suffices to show that for fixed $\ q_i$, $\ I[q_1,...,q_n]$ is an extremum of $\ J[q_1,..., q_n, p_1,..., p_n]$ taken over all possible choices of the functions $\ p_i$. Symbolically,

$I[q_1,..., q_n] = ext_{p_1,...,p_n} J[q_1,...,q_n,p_1,...,p_n]$

Then any extremum of $\ I[q_1,...,q_n]$, taken over all possible choices of the functions $\ q_i$, will be an extremum of $\ J[q_1,..., q_n, p_1,..., p_n]$ taken over all possible choices of the functions $\ p_i$ and $\ q_i$. Symbolically,

$ext_{q_1,...,q_n} I[q_1,..., q_n] = ext_{q_1,...,q_n} ext_{p_1,...,p_n} J[q_1,...,q_n,p_1,...,p_n]$

Since $\ J[q_1,..., q_n, p_1,..., p_n]$ does not depend on $\ \dot{p_i}$, it follows from the Euler-Lagrange equations (obtained when $\ p_i$ is varied and $\ q_i$ is fixed) that

$\frac{\partial}{\partial p_i} [- H + \displaystyle{\sum_{i=1}^n p_i \dot{q_i} }] = 0$, for $i = 1,...,n$.

This implies that $\dot{q_i} = \frac{\partial H}{\partial p_i}$. Let $\ p_i^0$, $i = 1,...,n$, satisfy the equation $J[q_1,...,q_n,p_1^0,...,p_n^0] = ext_{p_1,...,p_n} J[q_1,...,q_n,p_1,...,p_n]$.

Since $- H + \displaystyle{\sum_{i=1}^n p_i \frac{\partial H}{\partial p_i} } = L$, it follows that $- H + \displaystyle{\sum_{i=1}^n p_i^0 \dot{q_i} } = L$, and hence,

$I[q_1,...,q_n] = J[q_1,...,q_n,p_1^0,...,p_n^0] = ext_{p_1,...,p_n} J[q_1,...,q_n,p_1,...,p_n]$.

This proves the equivalence of the Euler-Lagrange and Hamiltonian formulations of the mechanics of a system of particles.

Remark: Lagrange’s equations for a system of particles described by $n$ coordinates can be shown to be equivalent to Newton’s law

$m \ddot{q_i} + \frac{\partial V}{\partial q_i} = 0, i = 1,...,n$,

where $\ V(q_1,...,q_n)$ denotes the potential energy of the system.

Hence, Lagrangian Mechanics, Hamiltonian mechanics, and Newton’s laws are equivalent ways of describing the dynamics of the system.

Reference: Calculus of Variations by I.M. Gelfand & S.V. Fomin (translated and edited by Richard A. Silverman), 1991.

## Complex Notation for Hamilton’s Equations

Consider Hamilton’s equations:

$\begin{cases} \dot{q_j} = \frac{\partial H}{\partial p_j}, \qquad j=1,...,n \\ \dot{p_j} = - \frac{\partial H}{\partial q_j} \end{cases}$

Suppose we let

$\ z_j = \frac{1}{2} \left( p_j + i q_j \right), \quad j = 1,...,n$

$\ z_j$ and $\ \bar{z_j}$ give $\ q_j$ and $\ p_j$ and vice-versa, so we can express $\ H(q_1,...,q_n,p_1,...,p_n, t)$ as $\ H(z, \bar{z}, t)$, where $\ z=(z_1,...,z_n)$, and $\ \bar{z} = (\bar{z_1},...,\bar{z_n})$. Consider the following system of $n$ equations in the complex variables $\ z_j(t)$ given by

$\ \dot{z_j} = i \frac{\partial H}{\partial \bar{z_j}}, \quad j=1,...,n$

This system is equivalent to Hamilton’s equations. Indeed,

\begin{align} i \frac{\partial H}{\partial \bar{z_j}} & = \frac{i}{2} \left( \frac{\partial}{\partial p_j} + i \frac{\partial}{\partial q_j} \right) H \\ & = \frac{1}{2} \left( - \frac{\partial}{\partial q_j} + i \frac{\partial}{\partial q_j} \right) H \end{align}

so equating the real and imaginary parts of this expression with those of $\ \dot{z_j}$ yields Hamilton’s equations.

Reference: Prof. J. Colliander's lecture notes for MAT495H1 on May 12, 2010.

## Consequences of the Hamiltonian formulation

Having shown the equivalence of the Hamiltonian formulation of mechanics to the Lagrangian formulation, it is natural to ask whether the Hamiltonian reformulation actually provides any new insights in the study of analytical mechanics. Several important results follow from formulating mechanics in terms of the momentum $\ p$ and the Hamiltonian $\ H(q,p)$ (without loss of generality, let’s take $n = 1$). One of which is the following:

Proposition: Hamilton’s principle holds for independent variations of $\ q$ and $\ p$ i.e. $\ \delta q$ and $\ \delta p$ (respectively, the infinitesimal variations in $\ q$ and $\ p$ from a physical path in $\ (q, p)$ phase space) are independent at each point in time (unlike $\ \delta q$ and $\ \delta \dot{q}$ ).

Proof: Hamilton’s principle requires the infinitesimal change in action, $\ \delta S$, resulting from the variations $\ \delta q$ and $\ \delta p$ to be zero. The following equation holds:

$\ \delta S = \int \limits_{t_1}^{t_2} \delta L \, dt$

By definition of the Hamiltonian, we have

$\ \delta L = \dot{q} \, \delta p + p \, \delta \dot{q} - \delta H$

Without loss of generality, assume that the Hamiltonian has no explicit time dependence. Therefore,

$\ \delta H = \frac{\partial H}{\partial q} \, \delta q + \frac{\partial H}{\partial p} \, \delta p$

Thus,

$\ \delta L = \left( \dot{q} - \frac{\partial H}{\partial p} \right) \, \delta p - \left( \dot{p} + \frac{\partial H}{\partial q} \, \delta q + \frac{d}{dt} (p \, \delta q) \right)$

Integrating the above equation with respect to time from $\ t_1$ to $\ t_2$, we find that the integral of the total time derivative term is zero if $\ \delta q = 0$ at the endpoints. Hamilton’s principle requires this condition to hold. So

$\ \delta S = \int \limits_{t_1}^{t_2} \left( \dot{q} - \frac{\partial H}{\partial p} \right) \delta p \, dt + \int \limits_{t_1}^{t_2} \left( - \dot{p} - \frac{\partial H}{\partial q} \right) \delta q \, dt$

It follows that $\ \delta S = 0$ for independent arbitrary variations of $\ p$ and $\ q$ if and only if the coefficients of $\ \delta p$ and $\ \delta q$ vanish; the latter condition is equivalent to Hamilton’s equations. The expression,

$dH = \dot{q} \, dp - \frac{\partial L}{\partial q} \, dq$

implies that Hamilton’s equations

$\ \dot{q} = \frac{\partial H}{\partial p}, \; \dot{p} = - \frac{\partial H}{\partial q}$

hold for independent variations of $\ q$ and $\ p$. This proves the proposition. It also follows that

$\ dH = \dot{q} \, dp - \dot{p} \, dq$

Note that in the above calculations, we required that $\ \delta q = 0$ at the endpoints, while $\ \delta p$ can vary at the endpoints. The coordinates $\ q$ and $\ p$ are almost symmetric if, in addition, we impose the condition that $\ \delta p = 0$ at the endpoints. This fact leads to the discovery of important theorems such as Liouville’s theorem and the Poincaré recurrence theorem. The symmetric treatment of $\ q$ and $\ p$ suggests that we can transform coordinates freely without thinking about whether a coordinate represents position or momentum. In fact, we use canonical transformations to find a new set of canonically conjugate coordinates in which a Hamiltonian system can be more easily solved. One such set of coordinates is the action-angle coordinates.

References: