The Legendre transform and Hamilton's equations
D-004 Home PU-201 Threads energy · symmetry Depends on D-001 verified
Statement
Trading velocity for momentum as the independent variable converts n second-order equations into 2n first-order ones, and the trade is performed by a Legendre transform.
Why it matters
The same operation appears twice in an undergraduate degree and is almost never identified as the same operation. In mechanics it takes L(q, q̇) to H(q, p). In thermodynamics it takes U(S, V) to F(T, V) and G(T, P). Cross-linking these two is one of the clearest wins available on the site — see D-016.
Assumptions
Derivation
Result
Reading. Motion becomes a flow in a 2n-dimensional phase space. The state is a point; the Hamiltonian is a function on that space; the dynamics is the vector field it generates. The antisymmetry between the two equations is the seed of the symplectic structure and of D-005.
Units check. ∂H/∂p is [energy]/[momentum] = velocity. ✓
Limiting cases
The same operation in thermodynamics. Start from dU = T dS − P dV, where the natural variables are S and V. To swap S for T, define F = U − TS. Then dF = −S dT − P dV — the dS terms cancel exactly as the dq̇ terms did at step 3. It is the same transform with (q̇, p, L) replaced by (S, T, U), and the sign convention differing only by taste. Continue in D-016.
Breaks when
- The momenta are not independent functions of the velocities — gauge systems, where the Legendre transform is degenerate and constrained dynamics is required.
- L is non-convex in q̇ — the transform is multivalued.
Failure modes
- Leaving q̇ in the expression for H. The transform is not complete until every velocity has been eliminated in favour of momentum; a Hamiltonian containing q̇ is meaningless.
- Assuming the conjugate momentum equals mv. For a charged particle in a magnetic field p = mv + qA, and the difference is the whole of the Aharonov–Bohm effect.
Worked number
Take the simplest non-trivial Hamiltonian, a free particle in one dimension, H = p2/2m. The first of Hamilton's equations gives q̇ = ∂H/∂p = p/m, and the second gives ṗ = −∂H/∂q = 0.
Momentum is conserved and the velocity recovered from ∂H/∂p matches p/m — the units check delivered on a number. Run the check →
Discussion
The Legendre transform carries no new physics. It contains exactly the information already in the Lagrangian, re-packaged so that a different pair of variables is primary. What changes is the shape of the equations of motion. Euler–Lagrange gives n second-order equations, one per coordinate, and a second-order equation needs two initial data (position and velocity) to be solved. Hamilton's equations replace them with 2n first-order equations, one for each coordinate and one for each momentum, and a first-order system needs one datum per equation — the same total count, 2n, now read as a single point in a 2n-dimensional phase space. The physical picture that follows is the whole payoff: a mechanical state is a point (q,p), the Hamiltonian is a scalar function defined on that space, and the motion is the flow of the vector field that H generates. Time evolution becomes geometry.
The result is structured the way it is because of the sign asymmetry in the pair q̇i = ∂H/∂pi, ṗi = −∂H/∂qi. That single minus sign is not cosmetic. It says that q and p are not interchangeable labels but a conjugate pair: each drives the other's rate of change with opposite signs, which is precisely the structure of a rotation, or more generally of an area-preserving flow. Written compactly, ξ̇ = J ∇H with J the antisymmetric J2 = −I matrix, and the whole of Hamiltonian mechanics is the study of what this antisymmetric object — the symplectic form — permits. It is the seed of D-005 (Liouville's theorem and conservation of phase-space volume) and of the Poisson-bracket algebra.
The transform's deepest content is duality. Because L is assumed convex in q̇, the Legendre transform is involutive: transforming H back returns L exactly, so no information is created or destroyed and neither description is privileged. This same convex-duality machinery reappears far outside mechanics. In thermodynamics it is the entire tower of potentials — U→F=U−TS, U→H=U+PV, U→G — each swapping an extensive variable for its conjugate intensive one, cancelling a differential term exactly as the dq̇ terms cancelled at step 3 (see D-016). It is the Wick-rotated bridge to the path integral, the relation between a Lagrangian density and a Hamiltonian density in field theory, and, through the identification of p with −iℏ∂q, the doorway to canonical quantization: you quantize the Hamiltonian, never the Lagrangian, because q and p are the pair that satisfies [q,p] = iℏ.
There is also a subtlety worth stating plainly at degree level. The Legendre transform is only as good as the invertibility of p = ∂L/∂q̇. When the Hessian ∂2L/∂q̇i∂q̇j is singular — as it is for any gauge theory, including free electromagnetism — some velocities cannot be solved for. The Legendre transform is then degenerate, momenta obey primary constraints, and Dirac's constrained-Hamiltonian formalism is needed to recover a consistent dynamics. This is not a pathology to be avoided; it is the generic situation for the fundamental fields of nature, and the constraints turn out to be the generators of the gauge symmetry itself.
Common misconceptions. The most persistent error is treating the conjugate momentum as if it were always mass times velocity. It equals mv only for a plain kinetic term; add a velocity-dependent interaction and the two part ways. For a charge q in a magnetic field the canonical momentum is p = mv + qA, and the gap between canonical and kinetic momentum is exactly what the Aharonov–Bohm effect measures. A second error is to imagine the Hamiltonian is always the energy; it equals the energy only when the coordinates are time-independent and the potential is velocity-independent, and it is conserved only when ∂H/∂t = 0. A third, purely procedural, error is to leave a velocity q̇ sitting inside H: the transform is not finished until every velocity has been eliminated in favour of momentum, because H is by construction a function of q and p alone.
Worked examples
Example 1 — Hamiltonian of the simple harmonic oscillator. A mass on a spring, m = 0.20 kg, k = 8.0 N m−1, released from q0 = 5.0 cm at rest. Build the Hamiltonian by Legendre transform and extract the motion.
Answer. The oscillator moves on a closed ellipse in phase space with angular frequency ω = 6.32 rad s−1 (period 0.99 s), total energy 1.0×10−2 J, and phase-space area 9.9×10−3 J s per cycle.
Example 2 — Charged particle in a uniform magnetic field: canonical vs kinetic momentum. A particle of charge q and mass m moves in the plane in a field B = Bẑ, described in the Landau gauge A = (−By, 0, 0). Build the Hamiltonian and show a cyclic coordinate delivers a conserved (canonical) momentum that is not the kinetic momentum. Evaluate for an electron in B = 0.10 T.
Answer. The canonical momentum px = mẋ − qBy is conserved because x is cyclic, yet it differs from the kinetic momentum mẋ by the field term. The electron circulates at ωc = 1.76×1010 rad s−1, radius ≈ 57 μm for v = 106 m s−1.
Problems
- Free particle. For L = ½mẋ2, construct H, write Hamilton's equations, and solve them. Which quantity is conserved and why?
Solution
p = ∂L/∂ẋ = mẋ, so ẋ = p/m and H = pẋ − L = p2/2m. Hamilton's equations: ẋ = ∂H/∂p = p/m, ṗ = −∂H/∂x = 0. Since H does not contain x (cyclic coordinate), p is conserved: p = p0. Integrating, x(t) = x0 + (p0/m)t — uniform motion, Newton's first law recovered.
- Uniform gravitational field. A particle falls under gravity with L = ½mż2 − mgz. Find H, write Hamilton's equations, and solve for z(t) with z(0)=h, ż(0)=0. Take g=9.81 m s−2, h=20 m; when does it land?
Solution
p = mż, so H = p2/2m + mgz. Hamilton's equations: ż = p/m, ṗ = −∂H/∂z = −mg. Thus p(t) = −mgt and ż = −gt, giving z(t) = h − ½gt2. Landing (z=0): t = √(2h/g) = √(40/9.81) = 2.02 s. Note H here equals the total mechanical energy and is conserved (no explicit t), while p is not conserved because z is not cyclic.
- Plane pendulum. A bob of mass m on a rigid rod of length ℓ has L = ½mℓ2θ̇2 + mgℓcosθ. Find the conjugate momentum, the Hamiltonian, Hamilton's equations, and the small-oscillation frequency.
Solution
pθ = ∂L/∂θ̇ = mℓ2θ̇, so θ̇ = pθ/mℓ2 and H = pθ2/2mℓ2 − mgℓcosθ. Hamilton's equations: θ̇ = ∂H/∂pθ = pθ/mℓ2, ṗθ = −∂H/∂θ = −mgℓsinθ. Combining: θ̈ = −(g/ℓ)sinθ. For small θ, sinθ≈θ, so ω = √(g/ℓ). The phase portrait shows closed orbits (libration) for H < mgℓ and open orbits (rotation) above it, separated by the separatrix through the unstable top.
- The transform in thermodynamics (enthalpy). Starting from dU = TdS − PdV, perform the Legendre transform that swaps the volume V for its conjugate pressure P. Identify the natural variables of the new potential and derive the associated Maxwell relation. Compare, term by term, with step 3 of the mechanics derivation.
Solution
Define the enthalpy H ≡ U + PV (the +PV plays the role of the +pq̇ term). Then dH = dU + PdV + VdP = (TdS − PdV) + PdV + VdP = TdS + VdP. The −PdV term cancels against +PdV exactly as the dq̇ terms cancelled in step 3 — the defining property of the transform. The natural variables are (S,P), with T = (∂H/∂S)P and V = (∂H/∂P)S. Equality of the mixed second partials, ∂2H/∂P∂S = ∂2H/∂S∂P, gives the Maxwell relation (∂T/∂P)S = (∂V/∂S)P. This is literally the same operation as L→H, with (q̇,p,L) ↔ (V,−P,U).
- Relativistic free particle (advanced). For a free relativistic particle L = −mc2√(1 − ẋ2/c2). Compute the conjugate momentum, invert it, and show by Legendre transform that H = √(p2c2 + m2c4). Check the rest-energy and non-relativistic limits.
Solution
p = ∂L/∂ẋ = mẋ/√(1−ẋ2/c2) = γmẋ — the relativistic momentum. Solving for the velocity: p2(1−ẋ2/c2) = m2ẋ2 ⇒ ẋ = pc/√(p2+m2c2). Then H = pẋ − L = pẋ + mc2√(1−ẋ2/c2). Substituting ẋ and simplifying (or noting H = γmc2 and γ2 = 1 + p2/m2c2) gives H = √(p2c2 + m2c4). Limits: at p→0, H→mc2 (rest energy); expanding for p≪mc, H ≈ mc2 + p2/2m — the rest energy plus the familiar non-relativistic kinetic term. The convexity of L in ẋ on |ẋ|<c guarantees the transform is single-valued and involutive.