Categories: Classical mechanics, Physics.

**Hamiltonian mechanics** is an alternative formulation of classical mechanics, which equivalent to Newton’s laws, but often mathematically advantageous. It is built on the shoulders of Lagrangian mechanics, which is in turn built on variational calculus.

In Lagrangian mechanics, use a Lagrangian \(L\), which depends on position \(q(t)\) and velocity \(\dot{q}(t)\), to define the momentum \(p(t)\) as a derived quantity. Hamiltonian mechanics switches the roles of \(\dot{q}\) and \(p\): the **Hamiltonian** \(H\) is a function of \(q\) and \(p\), and the velocity \(\dot{q}\) is derived from it:

\[\begin{aligned} \pdv{L(q, \dot{q})}{\dot{q}} = p \qquad \quad \pdv{H(q, p)}{p} \equiv \dot{q} \end{aligned}\]

Conveniently, this switch turns out to be Legendre transformation: \(H\) is the Legendre transform of \(L\), with \(p = \partial L / \partial \dot{q}\) taken as the coordinate to replace \(\dot{q}\). Therefore:

\[\begin{aligned} \boxed{ H(q, p) \equiv \dot{q} \: p - L(q, \dot{q}) } \end{aligned}\]

This almost always works, because \(L\) is usually a second-order polynomial of \(\dot{q}\), and thus convex as required for Legendre transformation. In the above expression, \(\dot{q}\) must be rewritten in terms of \(p\) and \(q\), which is trivial, since \(p\) is proportional to \(\dot{q}\) by definition.

The Hamiltonian \(H\) also has a direct physical meaning: for a mass \(m\), and for \(L = T - V\), it is straightforward to show that \(H\) represents the total energy \(T + V\):

\[\begin{aligned} H = \dot{q} \: p - L = m \dot{q}^2 - L = 2 T - (T - V) = T + V \end{aligned}\]

Just as Lagrangian mechanics, Hamiltonian mechanics scales well for large systems. Its definition is generalized as follows to \(N\) objects, where \(p\) is shorthand for \(p_1, ..., p_N\):

\[\begin{aligned} \boxed{ H(q, p) \equiv \bigg( \sum_{n = 1}^N \dot{q}_n \: p_n \bigg) - L(q, \dot{q}) } \end{aligned}\]

The positions and momenta \((q, p)\) form a phase space, i.e. they fully describe the state.

An extremely useful concept in Hamiltonian mechanics is the **Poisson bracket** (PB), which is a binary operation on two quantities \(A(q, p)\) and \(B(q, p)\), denoted by \(\{A, B\}\):

\[\begin{aligned} \boxed{ \{ A, B \} \equiv \sum_{n = 1}^N \Big( \pdv{A}{q_n} \pdv{B}{p_n} - \pdv{A}{p_n} \pdv{B}{q_n} \Big) } \end{aligned}\]

Lagrangian mechanics has a single Euler-Lagrange equation per object, yielding \(N\) second-order equations of motion in total. In contrast, Hamiltonian mechanics has \(2 N\) first-order equations of motion, known as **Hamilton’s canonical equations**:

\[\begin{aligned} \boxed{ - \pdv{H}{q_n} = \dot{p}_n \qquad \pdv{H}{p_n} = \dot{q}_n } \end{aligned}\]

For the first equation, we differentiate \(H\) with respect to \(q_n\), and use the chain rule: \[\begin{aligned} \pdv{H}{q_n} &= \pdv{q_n} \Big( \sum_{j} \dot{q}_j \: p_j - L \Big) \\ &= \sum_{j} \bigg( \Big( \dot{q}_j \pdv{p_j}{q_n} + p_j \pdv{\dot{q}_j}{q_n} \Big) - \Big( \pdv{L}{q_n} + \pdv{L}{\dot{q}_j} \pdv{\dot{q}_j}{q_n} \Big) \bigg) \\ &= \sum_{j} \Big( p_j \pdv{\dot{q}_j}{q_n} - \pdv{L}{q_n} - p_j \pdv{\dot{q}_j}{q_n} \Big) = - \pdv{L}{q_n} \end{aligned}\]

We use the Euler-Lagrange equation here, leading to the desired equation:

\[\begin{aligned} - \pdv{L}{q_n} = - \dv{t} \Big( \pdv{L}{\dot{q}_n} \Big) = - \dv{p_n}{t} = - \dot{p}_n \end{aligned}\]

The second equation is somewhat trivial, since \(H\) is defined to satisfy it in the first place. Nevertheless, we can prove it by brute force, using the same approach as above: \[\begin{aligned} \pdv{H}{p_n} &= \pdv{p_n} \Big( \sum_{j} \dot{q}_j \: p_j - L \Big) \\ &= \sum_{j} \bigg( \Big( \dot{q}_j \pdv{p_j}{p_n} + p_j \pdv{\dot{q}_j}{p_n} \Big) - \Big( \pdv{L}{q_j} \pdv{q_j}{p_n} + \pdv{L}{\dot{q}_j} \pdv{\dot{q}_j}{p_n} \Big) \bigg) \\ &= \dot{q}_n + \sum_{j} \Big( p_j \pdv{\dot{q}_j}{p_n} - 0 \pdv{L}{q_j} - p_j \pdv{\dot{q}_j}{p_n} \Big) = \dot{q}_n \end{aligned}\]

Just like in Lagrangian mechanics, if \(H\) does not explicitly contain \(q_n\), then \(q_n\) is called a **cyclic coordinate**, and leads to the conservation of \(p_n\):

\[\begin{aligned} \dot{p}_n = - \pdv{H}{q_n} = 0 \quad \implies \quad p_n = \mathrm{conserved} \end{aligned}\]

Of course, there may be other conserved quantities. Generally speaking, the \(t\)-derivative of an arbitrary quantity \(A(q, p, t)\) is as follows, where \(\pdv*{t}\) is a “soft” derivative (only affects explicit occurrences of \(t\)), and \(\dv*{t}\) is a “hard” derivative (also affects implicit \(t\) inside \(q\) and \(p\)):

\[\begin{aligned} \boxed{ \dv{A}{t} = \{ A, H \} + \pdv{A}{t} } \end{aligned}\]

We differentiate via the multivariate chain rule, insert the canonical equations, and eventually recognize the PB definition:

\[\begin{aligned} \dv{A}{t} &= \sum_{n} \Big( \pdv{A}{q_n} \pdv{q_n}{t} + \pdv{A}{p_n} \pdv{p_n}{t} \Big) + \pdv{A}{t} \\ &= \sum_{n} \Big( \pdv{A}{q_n} \dot{q}_n + \pdv{A}{p_n} \dot{p}_n \Big) + \pdv{A}{t} \\ &= \sum_{n} \Big( \pdv{A}{q_n} \pdv{H}{p_n} - \pdv{A}{p_n} \pdv{H}{q_n} \Big) + \pdv{A}{t} \end{aligned}\]

Assuming that \(H\) does not explicitly depend on \(t\), the above property naturally leads us to an alternative way of writing Hamilton’s canonical equations:

\[\begin{aligned} \dot{q}_n = \{ q_n, H \} \qquad \quad \dot{p}_n = \{ p_n, H \} \end{aligned}\]

So far, we have assumed that the phase space coordinates \((q, p)\) are the *positions* and *canonical momenta*, respectively, and that led us to Hamilton’s canonical equations.

In theory, we could make a transformation of the following general form:

\[\begin{aligned} q \to Q(q, p) \qquad \quad p \to P(q, p) \end{aligned}\]

However, most choices of \((Q, P)\) would not preserve Hamilton’s equations. Any \((Q, P)\) that do keep this form are known as **canonical coordinates**, and the corresponding transformation is a **canonical transformation**. That is, any \((Q, P)\) that satisfy:

\[\begin{aligned} - \pdv{H}{Q_n} = \dot{P}_n \qquad \quad \pdv{H}{P_n} = \dot{Q}_n \end{aligned}\]

Then we might as well write \(H(q, p)\) as \(H(Q, P)\). So, which \((Q, P)\) fulfill this? It turns out that the following must be satisfied for all \(n, j\), where \(\delta_{nj}\) is the Kronecker delta:

\[\begin{aligned} \boxed{ \{ Q_n, Q_j \} = \{ P_n, P_j \} = 0 \qquad \{ Q_n, P_j \} = \delta_{nj} } \end{aligned}\]

Assuming that \(Q_n\), \(P_n\) and \(H\) do not explicitly depend on \(t\), we use our expression for the \(t\)-derivative of an arbitrary quantity, and apply the multivariate chain rule to it:

\[\begin{aligned} \dot{Q}_n &= \{Q_n, H\} = \sum_{n} \bigg( \pdv{Q_n}{q_n} \pdv{H}{p_n} - \pdv{Q_n}{p_n} \pdv{H}{q_n} \bigg) \\ &= \sum_{n, j} \bigg( \pdv{Q_n}{q_n} \Big( \pdv{H}{Q_j} \pdv{Q_j}{p_n} + \pdv{H}{P_j} \pdv{P_j}{p_n} \Big) - \pdv{Q_n}{p_n} \Big( \pdv{H}{Q_j} \pdv{Q_j}{q_n} + \pdv{H}{P_j} \pdv{P_j}{q_n} \Big) \bigg) \\ &= \sum_{n, j} \bigg( \pdv{H}{Q_j} \Big( \pdv{Q_n}{q_n} \pdv{Q_j}{p_n} - \pdv{Q_n}{p_n} \pdv{Q_j}{q_n} \Big) + \pdv{H}{P_j} \Big( \pdv{Q_n}{q_n} \pdv{P_j}{p_n} - \pdv{Q_n}{p_n} \pdv{P_j}{q_n} \Big) \bigg) \\ &= \sum_{j} \bigg( \pdv{H}{Q_j} \{Q_n, Q_j\} + \pdv{H}{P_j} \{Q_n, P_j\} \bigg) \end{aligned}\]

This is equivalent to Hamilton’s equation \(\dot{Q}_n = \pdv*{H}{P_n}\) if and only if \(\{Q_n, Q_j\} = 0\) for all \(n\) and \(j\), and if \(\{Q_n, P_j\} = \delta_{nj}\).

Next, we do the exact same thing with \(P_n\) instead of \(Q_n\), giving an analogous result:

\[\begin{aligned} \dot{P}_n &= \{P_n, H\} = \sum_{n} \bigg( \pdv{P_n}{q_n} \pdv{H}{p_n} - \pdv{P_n}{p_n} \pdv{H}{q_n} \bigg) \\ &= \sum_{n, j} \bigg( \pdv{P_n}{q_n} \Big( \pdv{H}{Q_j} \pdv{Q_j}{p_n} + \pdv{H}{P_j} \pdv{P_j}{p_n} \Big) - \pdv{P_n}{p_n} \Big( \pdv{H}{Q_j} \pdv{Q_j}{q_n} + \pdv{H}{P_j} \pdv{P_j}{q_n} \Big) \bigg) \\ &= \sum_{n, j} \bigg( \pdv{H}{Q_j} \Big( \pdv{P_n}{q_n} \pdv{Q_j}{p_n} - \pdv{P_n}{p_n} \pdv{Q_j}{q_n} \Big) + \pdv{H}{P_j} \Big( \pdv{P_n}{q_n} \pdv{P_j}{p_n} - \pdv{P_n}{p_n} \pdv{P_j}{q_n} \Big) \bigg) \\ &= \sum_{j} \bigg( \pdv{H}{Q_j} \{P_n, Q_j\} + \pdv{H}{P_j} \{P_n, P_j\} \bigg) \end{aligned}\]

Which is equivalent to Hamilton’s equation \(\dot{P}_n = -\pdv*{H}{Q_n}\) if and only if \(\{P_n, P_j\} = 0\), and \(\{Q_n, P_j\} = - \delta_{nj}\). The PB is anticommutative, i.e. \(\{A, B\} = - \{B, A\}\).

If you have experience with quantum mechanics, the latter equation should look suspiciously similar to the *canonical commutation relation* \([\hat{Q}, \hat{P}] = i \hbar\).

- R. Shankar,
*Principles of quantum mechanics*, 2nd edition, Springer.

© Marcus R.A. Newman, a.k.a. "Prefetch".
Available under CC BY-SA 4.0.