The Hamiltonian and Phase Space
Lagrangian mechanics describes a system by its coordinates and velocities
(q, \dot q), and gives one second-order equation per degree of freedom.
There is a second great reformulation, due to Hamilton, that trades velocities for
momenta and each second-order equation for a pair of tidy first-order ones. The
payoff is not just algebraic neatness. It reveals a new arena — phase space — in
which the entire past and future of a system is a single point gliding along a fixed track, and it is
the language in which classical mechanics hands over to statistical mechanics and quantum theory.
We build it in three moves: the Legendre transform that swaps
\dot q for p, Hamilton's equations
that replace Euler–Lagrange, and the phase-space portrait that pictures the motion.
Everything rests on the Euler–Lagrange
equation and the conjugate momentum we met with cyclic coordinates.
The Legendre transform: from L to H
Start from the conjugate momentum p_i = \partial L/\partial \dot q_i. The
idea is to build a new function that depends on (q, p) instead of
(q, \dot q). The recipe is the Legendre transform:
H(q, p, t) = \sum_i p_i\,\dot q_i - L(q, \dot q, t),
where every \dot q_i on the right is re-expressed in terms of the momenta
by inverting p_i = \partial L/\partial \dot q_i. This H
is the Hamiltonian. You have already met its formula in disguise: it is exactly the
energy function h = \sum_i \dot q_i\,\partial L/\partial \dot q_i - L from
Noether's theorem, now regarded as a function of coordinates and momenta.
For the everyday case — kinetic energy quadratic in the velocities, a velocity-independent potential —
the transform delivers something wonderfully familiar:
- For a standard system, H = T + V — the total energy, written in terms
of coordinates and momenta.
- A free particle: H = \dfrac{p^2}{2m}. A particle in a potential:
H = \dfrac{p^2}{2m} + V(x). A harmonic oscillator:
H = \dfrac{p^2}{2m} + \tfrac12 k x^2.
- If H has no explicit time dependence, it is conserved — its constant
value is the system's energy.
Worked example. Take the harmonic oscillator,
L = \tfrac12 m\dot x^2 - \tfrac12 k x^2. The momentum is
p = \partial L/\partial \dot x = m\dot x, so
\dot x = p/m. Substitute:
H = p\,\dot x - L = p\cdot\frac{p}{m} - \left(\tfrac12 m\frac{p^2}{m^2} - \tfrac12 k x^2\right) = \frac{p^2}{2m} + \tfrac12 k x^2.
Exactly T + V, but now written with p where the
Lagrangian had \dot x.
Hamilton's equations
Once H(q, p) is in hand, the equations of motion take an almost impossibly
symmetric form. Where the Lagrangian gave n second-order equations,
Hamilton gives 2n first-order ones:
- \dot q_i = \frac{\partial H}{\partial p_i}
- \dot p_i = -\frac{\partial H}{\partial q_i}
The near-mirror symmetry between q and p (broken
only by a minus sign) is the seed of the whole subject. Test them on the oscillator
H = p^2/2m + \tfrac12 k x^2:
\dot x = \frac{\partial H}{\partial p} = \frac{p}{m}, \qquad \dot p = -\frac{\partial H}{\partial x} = -k x.
The first just restates p = m\dot x; differentiate it and substitute the
second to get m\ddot x = -kx — the oscillator equation, recovered. Notice a
cyclic coordinate reappears here too: if H does not contain
q_i, then \dot p_i = -\partial H/\partial q_i = 0
and that momentum is conserved, exactly as before.
Phase space: the whole story in one point
Here is the idea that makes the Hamiltonian view so powerful. Instead of plotting position against
time, plot momentum against position. A single point (q, p)
in this plane — called phase space — captures the complete state of the
system: give me both numbers now and Hamilton's equations tell me every number forever after. The
system's history is a curve threading through phase space, and because energy is conserved, the point
is trapped on a curve of constant H.
For the harmonic oscillator, constant H = p^2/2m + \tfrac12 kx^2 is the
equation of an ellipse. Each ellipse is one energy; bigger ellipses are more
energetic oscillations. Drag the slider to send the state point around its track — always
clockwise, because when x > 0 the force pushes
p down.
This picture generalises enormously. A system with n degrees of freedom
lives in a 2n-dimensional phase space, and its motion is a flow through that
space. Closed loops mean periodic motion; a point sitting still is an equilibrium; curves that spiral
in mean damping. Statistical mechanics counts states as volumes of phase space, and quantum mechanics
promotes q and p to operators — but the stage
was set here.
Liouville: phase-space flow is incompressible
One last gem falls straight out of Hamilton's equations. Imagine not one system but a whole
cloud of them — a little blob of nearby starting states drifting through phase space. As the
blob flows it can stretch and shear into fantastic filaments, but its volume never
changes. This is Liouville's theorem, and it follows because the
phase-space "velocity field" (\dot q, \dot p) has zero divergence:
\frac{\partial \dot q}{\partial q} + \frac{\partial \dot p}{\partial p} = \frac{\partial}{\partial q}\frac{\partial H}{\partial p} - \frac{\partial}{\partial p}\frac{\partial H}{\partial q} = 0.
Hamiltonian flow is incompressible: it can churn phase space like an honest fluid but
never squeeze it. This single fact underpins statistical mechanics (it lets us treat phase-space
volume as a conserved "amount of possibility") and forbids a friction-free Hamiltonian system from
ever settling onto a single attracting point — a first hint of why conservative systems can be chaotic
but never simply "run down."
The single most common Hamiltonian mistake is to write down H = T + V and
leave the kinetic energy as \tfrac12 m\dot x^2. That is only half
the transform. The Hamiltonian must be a function of coordinates and momenta — every
velocity has to be eliminated using \dot q = p/m (or whatever
p = \partial L/\partial \dot q gives). So the oscillator's kinetic term is
p^2/2m, not \tfrac12 m\dot x^2.
Why does it matter? Because Hamilton's equations take partial derivatives holding the other
variable fixed. If a stray \dot x is hiding in H,
then \partial H/\partial p is meaningless and you will get the wrong motion.
Numerically H and the energy agree, but symbolically H
must speak only the language of q and p.
No — and this is a subtlety worth knowing. H = T + V holds only when two
conditions are met: the coordinates do not depend explicitly on time (the constraints are
"scleronomic"), and the potential does not depend on velocity. Break the first — say you use a rotating
coordinate frame, or a bead on a wire that is being cranked round — and H is
still a perfectly good conserved quantity (if \partial H/\partial t = 0),
but it is not the mechanical energy T + V. Two separate questions
hide here: "Is H conserved?" (yes, whenever H has
no explicit time dependence) and "Is H the energy?" (yes, only for
time-independent coordinates). They usually coincide, which is exactly why it is easy to forget they
are different.