← Home · Mechanics and everyday physics · ← Lagrangian mechanics · Quaternions → · 🇩🇰 Dansk

Hamiltonian mechanics – the geometry of phase space

In 1834 the Irish mathematician and astronomer William Rowan Hamilton rewrote mechanics once more. Where Lagrange works with positions and velocities, Hamilton works with positions and momenta – and motion becomes a flow in a space in which every point is a possible state. That formulation became the foundation of statistical mechanics, chaos theory and quantum mechanics. Here are the theory, the classic examples and three interactive simulations.

From Lagrange to Hamilton

The starting point is the Lagrangian $L(q,\dot q,t)=T-V$. To each coordinate $q_i$ belongs a canonical momentum

$$p_i=\frac{\partial L}{\partial\dot q_i}.$$

Hamilton changes the independent variables: instead of $(q,\dot q)$ he uses $(q,p)$. The mathematical tool is a Legendre transformation – the same one that in thermodynamics leads from internal energy to enthalpy and free energy. The Hamiltonian is

$$H(q,p,t)=\sum_i p_i\dot q_i - L .$$

For most mechanical systems (where $T$ is quadratic in the velocities and $V$ depends only on position) $H = T+V$: the total energy, written as a function of positions and momenta. Lagrange's $n$ second-order differential equations become $2n$ first-order equations, Hamilton's equations:

$$\boxed{\;\dot q_i=\frac{\partial H}{\partial p_i},\qquad \dot p_i=-\frac{\partial H}{\partial q_i}\;}$$

The first equation says how velocity depends on momentum; the second is Newton's second law: the momentum is changed by the force $-\partial V/\partial q$. The difference in sign between the two equations is the whole secret. It makes energy conserved whenever $H$ does not depend explicitly on time:

$$\frac{\mathrm dH}{\mathrm dt}=\sum_i\Big(\frac{\partial H}{\partial q_i}\dot q_i+\frac{\partial H}{\partial p_i}\dot p_i\Big)+\frac{\partial H}{\partial t} =\sum_i\Big(\frac{\partial H}{\partial q_i}\frac{\partial H}{\partial p_i}-\frac{\partial H}{\partial p_i}\frac{\partial H}{\partial q_i}\Big)+\frac{\partial H}{\partial t}=\frac{\partial H}{\partial t}.$$

Phase space

Hamilton's equations are first order, so the state is completely fixed by one point $(q,p)$. The space of all such points is called phase space. For a pendulum it is two-dimensional: the angle horizontally and the angular momentum vertically. Hamilton's equations draw an arrow at every point, and the system follows the arrows like a droplet in a flowing liquid. Two paths in phase space can never cross – otherwise the same state would have two futures – and for a system with conserved energy each path lies on a level curve $H(q,p)=E$. So you can draw all the solutions without solving a single differential equation: they are just the contour lines on a map of $H$.

The pendulum's phase space – try it yourself

For a pendulum of length $\ell$ and mass $m$, $q=\theta$, $p=m\ell^2\dot\theta$ and (in units where $m\ell^2=1$ and $g/\ell=1$)

$$H(\theta,p)=\tfrac12 p^2-\cos\theta,\qquad \dot\theta=p,\qquad \dot p=-\sin\theta .$$

Small energies give closed curves around $(0,0)$: the pendulum swings to and fro (libration). Large energies give wavy lines that go all the way round: the pendulum turns somersaults (rotation). Between them lies the separatrix at $E=1$, on which the pendulum takes infinitely long to reach the top. Click in phase space to set a pendulum going – or release a whole droplet of 2000 pendulums with almost the same initial conditions.

Click or tap to start a pendulum
Try it yourself.
  1. Release a droplet near the separatrix and let it run for a while. It is drawn out into long, thin threads. Why do its points move differently when they have almost the same energy? (Hint: the period depends on the energy.)
  2. The "fine" area is conserved (Liouville) – but the coarse-grained area that a crude measurement would see grows. What has that to do with entropy? See The arrow of time.
  3. Press "Reverse". The leapfrog method is exactly time-reversible, so the droplet gathers itself up again – Loschmidt's objection to Boltzmann in one animation.
  4. Switch on friction. Now the droplet shrinks towards a point. Why can that never happen in a Hamiltonian system?

The energy landscape in 3D

Draw $H(\theta,p)$ as a surface over phase space. The pendulum's paths are the curves where the surface is cut by a horizontal plane at height $E$. The bottom of the valley at $(0,0)$ is the pendulum at rest; the two saddle points at $\theta=\pm\pi$ are the pendulum balancing upside down. Slide the plane up and down with the slider, and watch the path change character as the plane passes the saddle.

Drag: rotate · pinch/scroll: zoom
Try it yourself.
  1. Set $E$ just below 1 and just above 1. What happens to the period (shown at the top) near the separatrix?
  2. For small $E$ the cut is almost an ellipse. Why? (Hint: expand $-\cos\theta$ to second order.)

Worked examples

1. The harmonic oscillator

$$H=\frac{p^2}{2m}+\tfrac12 kq^2,\qquad \dot q=\frac pm,\quad \dot p=-kq .$$

The level curves are ellipses with semi-axes $\sqrt{2mE}$ and $\sqrt{2E/k}$. The area of the ellipse is $\oint p\,\mathrm dq=2\pi E/\omega$ with $\omega=\sqrt{k/m}$. Bohr and Sommerfeld set exactly this area equal to $nh$ – and obtained Planck's energy steps $E=nh\nu$.

2. A planet in polar coordinates

$$H=\frac{p_r^2}{2m}+\frac{p_\varphi^2}{2mr^2}-\frac{GMm}{r}.$$

$\varphi$ does not appear, so $\dot p_\varphi=-\partial H/\partial\varphi=0$: angular momentum is conserved. The radial motion becomes a one-dimensional problem with the effective potential $p_\varphi^2/(2mr^2)-GMm/r$ – the centrifugal barrier that keeps the planet away from the Sun.

3. A charged particle in a magnetic field

$$H=\frac{(\mathbf p-e\mathbf A)^2}{2m}+e\phi .$$

The canonical momentum $\mathbf p$ is not $m\mathbf v$ but $m\mathbf v+e\mathbf A$. In quantum mechanics it is $\mathbf p$ that becomes the operator $-i\hbar\nabla$, and that explains the Aharonov–Bohm effect: electrons feel the potential $\mathbf A$ even where the magnetic field is zero.

4. The double pendulum

Phase space is four-dimensional $(\theta_1,\theta_2,p_1,p_2)$, and the energy surface is three-dimensional. At low energy the paths lie on two-dimensional tori (KAM tori) and are regular. At high energy the tori break up, and the paths wander chaotically. See it on the Lagrange page.

Liouville's theorem: the phase-space fluid cannot be compressed

Imagine many copies of the same system with slightly different initial conditions – a cloud of points in phase space. The velocity field in phase space is $(\dot q,\dot p)=(\partial H/\partial p,\,-\partial H/\partial q)$, and its divergence is

$$\frac{\partial\dot q}{\partial q}+\frac{\partial\dot p}{\partial p}=\frac{\partial^2H}{\partial q\,\partial p}-\frac{\partial^2H}{\partial p\,\partial q}=0 .$$

The flow is therefore divergence-free, and the cloud's volume in phase space is conserved, however it is deformed (Joseph Liouville, 1838). The consequences are far-reaching:

Symplectic integrators: calculate the way nature does

Liouville's theorem is a geometrical property: Hamilton's flow preserves area (more precisely the symplectic form $\mathrm dq\wedge\mathrm dp$). A numerical method that also preserves area is called symplectic. The best known is Störmer–Verlet ("leapfrog"), in which momentum and position are updated alternately:

$$p_{n+\frac12}=p_n-\tfrac{h}{2}\,\partial_qV(q_n),\qquad q_{n+1}=q_n+h\,p_{n+\frac12}/m,\qquad p_{n+1}=p_{n+\frac12}-\tfrac h2\,\partial_qV(q_{n+1}).$$

The method is only second order, but the energy error does not grow with time – it oscillates. The classical fourth-order Runge–Kutta is far more accurate per step, but it is not symplectic, so the energy slowly leaks away. The simple Euler method adds energy at every step, and the planet spirals outwards. That is why symplectic methods are used for the evolution of the Solar System over billions of years, for molecular dynamics and for particle accelerators. Newton's impulse construction in Principia, Prop. 1 is, incidentally, exactly a symplectic Euler method: that is why the areas are exactly equal.

Try it yourself. Three planets start at the same place with the same speed and the same time step, but are computed with different methods. The graph on the right shows the energy error.
  1. Which planet keeps to its orbit after many revolutions? What does the energy error do for each method?
  2. Make $h$ very small. Which method is now most accurate – and why is that not enough in a long run?
  3. The Verlet orbit slowly turns (a spurious perihelion advance), but it remains an ellipse. Why is that less serious than a spiral?

Poisson brackets – and the road to quantum mechanics

For two quantities $f(q,p)$ and $g(q,p)$ the Poisson bracket is defined as

$$\{f,g\}=\sum_i\Big(\frac{\partial f}{\partial q_i}\frac{\partial g}{\partial p_i}-\frac{\partial f}{\partial p_i}\frac{\partial g}{\partial q_i}\Big),\qquad \frac{\mathrm df}{\mathrm dt}=\{f,H\}+\frac{\partial f}{\partial t}.$$

A quantity is conserved precisely when its bracket with $H$ is zero. The fundamental brackets are $\{q_i,p_j\}=\delta_{ij}$, and for the components of angular momentum $\{L_x,L_y\}=L_z$ and cyclically – the same structure as the quaternions' $ij=k$.

In 1925 the 23-year-old Paul Dirac read Heisenberg's first paper on matrix mechanics and saw that Heisenberg's commutation relation was a quantum version of the Poisson bracket:

$$\{f,g\}\;\longrightarrow\;\frac{1}{i\hbar}\,[\hat f,\hat g],\qquad\text{so}\qquad \{q,p\}=1\;\longrightarrow\;[\hat q,\hat p]=i\hbar .$$

Heisenberg's equation of motion $\mathrm d\hat f/\mathrm dt=\tfrac{1}{i\hbar}[\hat f,\hat H]$ is Hamilton's in new clothes, and the Hamiltonian became the Hamiltonian operator $\hat H$ of Schrödinger's equation. It was not Newton's forces or Lagrange's action but Hamilton's phase space that survived the passage into the quantum world – with the difference that $q$ and $p$ can no longer be known at the same time: a region of phase space smaller than $h$ has no meaning.

The Hamilton–Jacobi equation and the optical–mechanical analogy

Hamilton did not begin with mechanics but with optics. In "Theory of Systems of Rays" (1827–1832) he described light rays by a single characteristic function whose surfaces of constant value are the wavefronts, with the rays perpendicular to them. From the theory he predicted in 1832 conical refraction in biaxial crystals, which his colleague Humphrey Lloyd confirmed a few months later. Afterwards he applied exactly the same mathematics to mechanics. In the form Carl Jacobi gave it in 1837, the action $S(q,t)$ is determined by

$$\frac{\partial S}{\partial t}+H\Big(q,\frac{\partial S}{\partial q},t\Big)=0,\qquad p=\frac{\partial S}{\partial q}.$$

The particle paths are perpendicular to the surfaces $S=$ constant – just as light rays are to wavefronts. Hamilton saw that mechanics resembled ray optics. What corresponded to wave optics, nobody asked for 90 years. In 1926 Erwin Schrödinger took the step: he wrote the wave function as $\psi=e^{iS/\hbar}$ and looked for the wave equation that in the limit $\hbar\to0$ gives the Hamilton–Jacobi equation. The result was the Schrödinger equation.

History

Exercises

  1. Find the Hamiltonian for a particle falling vertically in a uniform gravitational field, and solve Hamilton's equations. Draw the paths in phase space $(z,p)$.
  2. Show that the area enclosed by the harmonic oscillator's path in phase space is $2\pi E/\omega$.
  3. Show that $\{L_x,L_y\}=L_z$, where $L_x=yp_z-zp_y$ etc.
  4. Show that the Euler method $q_{n+1}=q_n+hp_n$, $p_{n+1}=p_n-hkq_n$ for the harmonic oscillator multiplies the phase-space area by $1+h^2k$ at every step, while the symplectic Euler method (use $q_{n+1}$ instead of $q_n$ in the second equation) preserves it.

Sources and further reading

Related pages: The three-body problem · Least time and least action · Lagrangian mechanics · Quaternions · Newton's Principia · The arrow of time · Entropy · Gibbs' paradox.