Skip to content

Hamiltonian Mechanics

Attempt these from memory before reading.

  • Write down the Legendre transform. Why does it need the Hessian of LL to be non-singular?
  • State Hamilton’s equations. How many first-order equations do they give for nn degrees of freedom?
  • State Liouville’s theorem, and say what it rules out for Hamiltonian systems.
  • Write down the fundamental Poisson brackets.
  • What is a constant of motion in terms of the Poisson bracket with HH?

Motivation: why switch from the Lagrangian

Section titled “Motivation: why switch from the Lagrangian”

The Lagrangian gives nn second-order equations in the coordinates. Hamilton’s formulation rewrites them as 2n2n first-order equations in the coordinates and their conjugate momenta, treating (q,p)(q, p) as independent variables.

That looks like no gain at all — more variables, same information. What it buys is a different geometry:

  • Phase space is the natural home. A state of the system is a point (q,p)(q, p), not a path. Initial-value problems become: start here, follow the flow.
  • First order is what ODE theory wants. Existence, uniqueness and numerical integration are all theorems about first-order systems.
  • Conserved quantities become geometry. A cyclic coordinate makes pjp_j constant, so the flow is confined to a level surface of pjp_j. Conservation laws turn into constraints on where the orbit can go.
  • The transformation to quantum mechanics runs through it. The Poisson bracket is the classical object whose deformation gives the commutator.

The Lagrangian is the better formulation for solving a specific problem quickly; the Hamiltonian is the better one for understanding the structure of the solution space.

The generalised momentum conjugate to qjq_j is

pj=∂L∂q˙jp_j = \frac{\partial L}{\partial \dot{q}_j}

The Hamiltonian is defined by the Legendre transform:

H(q1,…,qn,p1,…,pn,t)=∑j=1npjq˙j−LH(q_1, \ldots, q_n, p_1, \ldots, p_n, t) = \sum_{j=1}^n p_j \dot{q}_j - L

When the transformation is regular (i.e., the Hessian ∂2L/∂q˙j∂q˙k\partial^2 L / \partial \dot{q}_j \partial \dot{q}_k Is non-singular), this is well-defined.

If LL does not depend explicitly on time and VV is velocity-independent, then H=T+VH = T + V (total Energy).

4.3 Worked Example: Legendre Transform for the Harmonic Oscillator

Section titled “4.3 Worked Example: Legendre Transform for the Harmonic Oscillator”

Problem. A one-dimensional harmonic oscillator has L=12mx˙2−12kx2L = \frac{1}{2}m\dot{x}^2 - \frac{1}{2}kx^2. Find the Hamiltonian.

Solution

The conjugate momentum:

p=∂L∂x˙=mx˙  ⟹  x˙=pmp = \frac{\partial L}{\partial \dot{x}} = m\dot{x} \implies \dot{x} = \frac{p}{m}

The Hamiltonian:

H=px˙−L=ppm−12mp2m2+12kx2=p22m+12kx2H = p\dot{x} - L = p\frac{p}{m} - \frac{1}{2}m\frac{p^2}{m^2} + \frac{1}{2}kx^2 = \frac{p^2}{2m} + \frac{1}{2}kx^2

This is T+VT + V as expected for a natural system. Hamilton’s equations give:

x˙=∂H∂p=pm,p˙=−∂H∂x=−kx\dot{x} = \frac{\partial H}{\partial p} = \frac{p}{m}, \quad \dot{p} = -\frac{\partial H}{\partial x} = -kx

Combining: x¨=p˙/m=−kx/m\ddot{x} = \dot{p}/m = -kx/m I.e., x¨+(k/m)x=0\ddot{x} + (k/m)x = 0. ■\blacksquare

4.4 Worked Example: Legendre Transform for the Simple Pendulum

Section titled “4.4 Worked Example: Legendre Transform for the Simple Pendulum”

Problem. Find the Hamiltonian for a simple pendulum of mass mm and length ll.

Solution

From Section 3.4, L=12ml2θ˙2+mglcos⁡θL = \frac{1}{2}ml^2\dot{\theta}^2 + mgl\cos\theta.

Conjugate momentum:

pθ=∂L∂θ˙=ml2θ˙  ⟹  θ˙=pθml2p_\theta = \frac{\partial L}{\partial \dot{\theta}} = ml^2\dot{\theta} \implies \dot{\theta} = \frac{p_\theta}{ml^2}

Hamiltonian:

H=pθθ˙−L=pθ2ml2−pθ22ml2−mglcos⁡θ=pθ22ml2−mglcos⁡θH = p_\theta\dot{\theta} - L = \frac{p_\theta^2}{ml^2} - \frac{p_\theta^2}{2ml^2} - mgl\cos\theta = \frac{p_\theta^2}{2ml^2} - mgl\cos\theta

Hamilton’s equations:

θ˙=∂H∂pθ=pθml2,p˙θ=−∂H∂θ=−mglsin⁡θ\dot{\theta} = \frac{\partial H}{\partial p_\theta} = \frac{p_\theta}{ml^2}, \quad \dot{p}_\theta = -\frac{\partial H}{\partial \theta} = -mgl\sin\theta

■\blacksquare

Theorem 4.1 (Hamilton’s Equations). The equations of motion in Hamiltonian form are

q˙j=∂H∂pj,p˙j=−∂H∂qj\dot{q}_j = \frac{\partial H}{\partial p_j}, \quad \dot{p}_j = -\frac{\partial H}{\partial q_j}

These are 2n2n first-order ODEs (compared to nn second-order ODEs in the Lagrangian formulation).

Proof. From H=∑pjq˙j−LH = \sum p_j \dot{q}_j - L:

dH=∑q˙j dpj+∑pj dq˙j−∑∂L∂qj dqj−∑∂L∂q˙j dq˙j−∂L∂t dtdH = \sum \dot{q}_j\, dp_j + \sum p_j\, d\dot{q}_j - \sum \frac{\partial L}{\partial q_j}\, dq_j - \sum \frac{\partial L}{\partial \dot{q}_j}\, d\dot{q}_j - \frac{\partial L}{\partial t}\, dt

Since pj=∂L/∂q˙jp_j = \partial L / \partial \dot{q}_j The dq˙jd\dot{q}_j terms cancel:

dH=∑q˙j dpj−∑p˙j dqj−∂L∂t dtdH = \sum \dot{q}_j\, dp_j - \sum \dot{p}_j\, dq_j - \frac{\partial L}{\partial t}\, dt

Comparing with dH=∑∂H∂pjdpj+∑∂H∂qjdqj+∂H∂tdtdH = \sum \frac{\partial H}{\partial p_j} dp_j + \sum \frac{\partial H}{\partial q_j} dq_j + \frac{\partial H}{\partial t} dt:

q˙j=∂H∂pj,p˙j=−∂H∂qj,∂H∂t=−∂L∂t\dot{q}_j = \frac{\partial H}{\partial p_j}, \quad \dot{p}_j = -\frac{\partial H}{\partial q_j}, \quad \frac{\partial H}{\partial t} = -\frac{\partial L}{\partial t}

■\blacksquare

Hamiltonian mechanics lives in phase space: the 2n2n-dimensional space with coordinates (q1,…,qn,p1,…,pn)(q_1, \ldots, q_n, p_1, \ldots, p_n). Each point in phase space represents a complete state of the System (positions and momenta).

A phase portrait is the collection of trajectories in phase space. For a 1D harmonic oscillator the trajectories are ellipses in the (x,p)(x, p) plane, and that single picture carries the physics in four representations at once.

The same oscillator, four ways.

In words. Energy sloshes between kinetic and potential. When the mass is at maximum displacement it is momentarily at rest; when it passes through the centre it is moving fastest.

As equations. H=p22m+12kx2=EH = \frac{p^2}{2m} + \frac{1}{2}kx^2 = E on each orbit, with x˙=p/m\dot x = p/m and p˙=−kx\dot p = -kx.

As a picture. Concentric ellipses in the (x,p)(x, p) plane:

p
^ .......
| ... ...
| . .
| . + . each ellipse is one energy
| . . E = H on the curve
| ... ...
| .......
+----------------------> x

As a statement about area. The area enclosed by an orbit is 2πE/ω2\pi E/\omega, so energy sets the area. Liouville’s theorem says a bundle of such orbits keeps its total area as it deforms.

The picture also explains why the origin is called a centre: orbits circle it but never approach it, so it is stable without being attracting. An attracting fixed point would require the area to shrink, which Liouville forbids.

Theorem 4.2 (Liouville’s Theorem). The flow in phase space is incompressible: the phase space volume is conserved along trajectories. Equivalently, the phase space density ρ(q,p,t)\rho(q, p, t) satisfies:

dρdt=∂ρ∂t+∑j(∂ρ∂qjq˙j+∂ρ∂pjp˙j)=0\frac{d\rho}{dt} = \frac{\partial \rho}{\partial t} + \sum_j \left(\frac{\partial \rho}{\partial q_j}\dot{q}_j + \frac{\partial \rho}{\partial p_j}\dot{p}_j\right) = 0

Proof. Consider a volume Ω\Omega in phase space. The rate of change of the volume is:

ddt∫Ωρ dq dp=∫Ω∂ρ∂t dq dp\frac{d}{dt}\int_\Omega \rho\, dq\, dp = \int_\Omega \frac{\partial \rho}{\partial t}\, dq\, dp

By the continuity equation in 2n2n dimensions:

∂ρ∂t+∇⋅(ρv)=0\frac{\partial \rho}{\partial t} + \nabla \cdot (\rho \mathbf{v}) = 0

Where v=(q˙1,…,q˙n,p˙1,…,p˙n)\mathbf{v} = (\dot{q}_1, \ldots, \dot{q}_n, \dot{p}_1, \ldots, \dot{p}_n) is the phase space velocity. Using Hamilton’s equations:

∇⋅v=∑j∂q˙j∂qj+∑j∂p˙j∂pj=∑j∂2H∂qj∂pj−∑j∂2H∂pj∂qj=0\nabla \cdot \mathbf{v} = \sum_j \frac{\partial \dot{q}_j}{\partial q_j} + \sum_j \frac{\partial \dot{p}_j}{\partial p_j} = \sum_j \frac{\partial^2 H}{\partial q_j \partial p_j} - \sum_j \frac{\partial^2 H}{\partial p_j \partial q_j} = 0

By equality of mixed partial derivatives. Therefore:

∂ρ∂t+ρ (∇⋅v)+v⋅∇ρ=∂ρ∂t+v⋅∇ρ=dρdt=0\frac{\partial \rho}{\partial t} + \rho\,(\nabla \cdot \mathbf{v}) + \mathbf{v} \cdot \nabla\rho = \frac{\partial \rho}{\partial t} + \mathbf{v} \cdot \nabla\rho = \frac{d\rho}{dt} = 0

■\blacksquare

Intuition. Liouville’s theorem is the classical analogue of unitarity in quantum mechanics. It tells us that phase space volume is conserved --- like an incompressible fluid flowing through phase space. This underlies the ergodic hypothesis of statistical mechanics.

Definition. The Poisson bracket of two functions f(q,p,t)f(q, p, t) and g(q,p,t)g(q, p, t) is:

{f,g}=∑j=1n(∂f∂qj∂g∂pj−∂f∂pj∂g∂qj)\{f, g\} = \sum_{j=1}^n \left(\frac{\partial f}{\partial q_j}\frac{\partial g}{\partial p_j} - \frac{\partial f}{\partial p_j}\frac{\partial g}{\partial q_j}\right)

Theorem 4.3 (Equations of Motion via Poisson Brackets). For any function f(q,p,t)f(q, p, t):

dfdt=∂f∂t+{f,H}\frac{df}{dt} = \frac{\partial f}{\partial t} + \{f, H\}

In particular, Hamilton’s equations become:

q˙j={qj,H},p˙j={pj,H}\dot{q}_j = \{q_j, H\}, \quad \dot{p}_j = \{p_j, H\}

Proof. Using the chain rule:

dfdt=∂f∂t+∑j(∂f∂qjq˙j+∂f∂pjp˙j)\frac{df}{dt} = \frac{\partial f}{\partial t} + \sum_j \left(\frac{\partial f}{\partial q_j}\dot{q}_j + \frac{\partial f}{\partial p_j}\dot{p}_j\right)

Substituting Hamilton’s equations:

dfdt=∂f∂t+∑j(∂f∂qj∂H∂pj−∂f∂pj∂H∂qj)=∂f∂t+{f,H}\frac{df}{dt} = \frac{\partial f}{\partial t} + \sum_j \left(\frac{\partial f}{\partial q_j}\frac{\partial H}{\partial p_j} - \frac{\partial f}{\partial p_j}\frac{\partial H}{\partial q_j}\right) = \frac{\partial f}{\partial t} + \{f, H\}

■\blacksquare

Properties of Poisson Brackets.

Theorem 4.4. The Poisson bracket satisfies:

  1. Antisymmetry: {f,g}=−{g,f}\{f, g\} = -\{g, f\}
  2. Linearity: {af+bg,h}=a{f,h}+b{g,h}\{af + bg, h\} = a\{f, h\} + b\{g, h\} for constants a,ba, b
  3. Leibniz rule: {fg,h}=f{g,h}+{f,h}g\{fg, h\} = f\{g, h\} + \{f, h\}g
  4. Jacobi identity: {f,{g,h}}+{g,{h,f}}+{h,{f,g}}=0\{f, \{g, h\}\} + \{g, \{h, f\}\} + \{h, \{f, g\}\} = 0

Proof. Properties (1)—(3) follow directly from the definition. For the Jacobi identity, write out the terms explicitly:

{f,{g,h}}=∑j∂f∂qj∂∂pj∑k(∂g∂qk∂h∂pk−∂g∂pk∂h∂qk)−∑j∂f∂pj∂∂qj∑k(∂g∂qk∂h∂pk−∂g∂pk∂h∂qk)\{f, \{g, h\}\} = \sum_j \frac{\partial f}{\partial q_j}\frac{\partial}{\partial p_j}\sum_k \left(\frac{\partial g}{\partial q_k}\frac{\partial h}{\partial p_k} - \frac{\partial g}{\partial p_k}\frac{\partial h}{\partial q_k}\right) - \sum_j \frac{\partial f}{\partial p_j}\frac{\partial}{\partial q_j}\sum_k \left(\frac{\partial g}{\partial q_k}\frac{\partial h}{\partial p_k} - \frac{\partial g}{\partial p_k}\frac{\partial h}{\partial q_k}\right)

Expanding and collecting terms, the second-order mixed partial derivatives cancel in groups of three (by equality of mixed partials), yielding the Jacobi identity. ■\blacksquare

Theorem 4.5. A quantity ff is a constant of motion if and only if ∂f/∂t+{f,H}=0\partial f/\partial t + \{f, H\} = 0. If ff does not depend explicitly on time, ff is conserved if and only if {f,H}=0\{f, H\} = 0.

Proof. Immediate from Theorem 4.3 with df/dt=0df/dt = 0. ■\blacksquare

Fundamental Poisson Brackets:

{qj,qk}=0,{pj,pk}=0,{qj,pk}=δjk\{q_j, q_k\} = 0, \quad \{p_j, p_k\} = 0, \quad \{q_j, p_k\} = \delta_{jk}
ClaimTrue?Counterexample
The Hamiltonian always equals T+VT + Vnoa charged particle in an EM field, or any rheonomic constraint: H=∑pjq˙j−LH = \sum p_j\dot q_j - L comes from the Legendre transform, not from T+VT + V
The Legendre transform always existsnoLL must be convex in q˙\dot q; for a relativistic particle near v=cv = c the Hessian degenerates
A Hamiltonian system always reaches equilibriumnoLiouville forbids attractors entirely
Every conserved quantity comes from a symmetry of qqnomomentum can be conserved with no obvious coordinate symmetry
Poisson brackets are invariant under any coordinate changenoonly under canonical transformations

The relativistic row is the one to remember. It shows that the Legendre transform is a hypothesis about the Lagrangian, not a formality, and that the transform breaks exactly where the physics becomes singular.

Mix these with material from Lagrangian mechanics, Noether’s theorem and the statistical mechanics module.

  1. (Lagrangian.) Show that the Legendre transform is an involution: applying it twice returns the original Lagrangian. Where is convexity used?
  2. (Noether.) For a particle in a central potential, show that rotational symmetry gives {Lz,H}=0\{L_z, H\} = 0 and hence LzL_z is conserved.
  3. (Statistical mechanics.) Show that the microcanonical measure on the energy surface H=EH = E is invariant under the flow, using Liouville’s theorem.
  4. (Symplectic structure.) Show that the Poisson bracket can be written {f,g}=ω(Xf,Xg)\{f, g\} = \omega(X_f, X_g) where ω\omega is the symplectic form.
  5. (Hamilton-Jacobi.) Show that if S(q,α,t)S(q, \alpha, t) is a complete integral depending on constants α\alpha, then the p=∂S/∂qp = \partial S/\partial q and β=∂S/∂α\beta = \partial S/\partial \alpha are constant along solutions.

Definition. Hamilton’s principal function S(q,t)S(q, t) is the action evaluated along the classical path from (q0,t0)(q_0, t_0) to (q,t)(q, t).

Theorem 4.6 (Hamilton-Jacobi Equation). The function SS satisfies:

H(q1,…,qn,∂S∂q1,…,∂S∂qn,t)+∂S∂t=0H\left(q_1, \ldots, q_n, \frac{\partial S}{\partial q_1}, \ldots, \frac{\partial S}{\partial q_n}, t\right) + \frac{\partial S}{\partial t} = 0

This is a first-order nonlinear PDE in n+1n + 1 variables.

Proof. The action from t0t_0 to tt is S=∫t0tL dt′S = \int_{t_0}^{t} L\, dt'. The total time derivative is:

dSdt=L\frac{dS}{dt} = L

But S=S(q1(t),…,qn(t),t)S = S(q_1(t), \ldots, q_n(t), t) So by the chain rule:

dSdt=∑j∂S∂qjq˙j+∂S∂t=L\frac{dS}{dt} = \sum_j \frac{\partial S}{\partial q_j}\dot{q}_j + \frac{\partial S}{\partial t} = L

From the definition of the conjugate momentum, pj=∂L/∂q˙j=∂S/∂qjp_j = \partial L/\partial \dot{q}_j = \partial S/\partial q_j (this can be shown rigorously by varying the endpoint). Therefore:

L=∑jpjq˙j+∂S∂t=H+∂S∂tL = \sum_j p_j \dot{q}_j + \frac{\partial S}{\partial t} = H + \frac{\partial S}{\partial t}

Since dS/dt=LdS/dt = L:

H+∂S∂t=L=∑jpjq˙j+∂S∂tH + \frac{\partial S}{\partial t} = L = \sum_j p_j\dot{q}_j + \frac{\partial S}{\partial t}

Which gives H+∂S/∂t=0H + \partial S/\partial t = 0. ■\blacksquare

Intuition. The Hamilton-Jacobi equation is the bridge between classical and quantum mechanics. Schrodinger’s equation can be obtained from it via the substitution S=−iℏln⁡ψS = -i\hbar \ln\psi (up to constants), making SS the classical limit of the quantum phase.

Separation of Variables. If HH does not depend explicitly on tt Write S(q,t)=W(q)−EtS(q, t) = W(q) - Et. Then the time-independent Hamilton-Jacobi equation is:

H(q1,…,qn,∂W∂q1,…,∂W∂qn)=EH\left(q_1, \ldots, q_n, \frac{\partial W}{\partial q_1}, \ldots, \frac{\partial W}{\partial q_n}\right) = E

Where WW is Hamilton’s characteristic function and EE is the constant energy.

4.10 Worked Example: Hamilton-Jacobi for the Harmonic Oscillator

Section titled “4.10 Worked Example: Hamilton-Jacobi for the Harmonic Oscillator”

Problem. Solve the Hamilton-Jacobi equation for a 1D harmonic oscillator with H=p2/(2m)+kx2/2H = p^2/(2m) + kx^2/2.

Solution

Since HH is time-independent, write S(x,t)=W(x)−EtS(x, t) = W(x) - Et. The HJ equation becomes:

12m(dWdx)2+12kx2=E\frac{1}{2m}\left(\frac{dW}{dx}\right)^2 + \frac{1}{2}kx^2 = E dWdx=2mE−mkx2\frac{dW}{dx} = \sqrt{2mE - mkx^2}

Integrating:

W(x)=∫2mE−mkx2 dxW(x) = \int \sqrt{2mE - mkx^2}\, dx

Let x=2E/ksin⁡αx = \sqrt{2E/k}\sin\alpha Then dx=2E/kcos⁡α dαdx = \sqrt{2E/k}\cos\alpha\, d\alpha:

W=2Eω∫0αcos⁡2α′ dα′=Eω(α+12sin⁡2α)W = \frac{2E}{\omega}\int_0^\alpha \cos^2\alpha'\, d\alpha' = \frac{E}{\omega}\left(\alpha + \frac{1}{2}\sin 2\alpha\right)

Where ω=k/m\omega = \sqrt{k/m}. The solution gives x(t)=2E/ksin⁡(ωt+δ)x(t) = \sqrt{2E/k}\sin(\omega t + \delta) as expected.

■\blacksquare

Hamiltonian mechanics is like switching from a video recording of motion to a snapshot of all possible states. While the Lagrangian tracks positions and velocities over time, the Hamiltonian lives in phase space where every point represents a complete snapshot of where something is and how fast it is going. Hamilton’s equations are beautifully symmetric: the rate of change of position depends on how energy changes with momentum, and the rate of change of momentum depends on how energy changes with position. Liouville’s theorem tells us that if you paint a region of phase space, its volume stays the same as it flows around like incompressible paint. This is why statistical mechanics works: the phase space volume that encodes all possible states of a system is preserved under time evolution.

Mistake 1: Assuming the Hamiltonian always equals T+VT + V The Hamiltonian equals the total energy H=T+VH = T + V only when the potential is velocity-independent and the coordinate transformation is scleronomic. For systems with velocity-dependent potentials (like charged particles in electromagnetic fields) or rheonomic constraints, H≠T+VH \neq T + V even though HH is still conserved when ∂L/∂t=0\partial L/\partial t = 0.

Mistake 2: Confusing canonical momentum with mechanical momentum Canonical momentum pj=∂L/∂q˙jp_j = \partial L/\partial \dot{q}_j is not always equal to mechanical momentum mq˙jm\dot{q}_j. For a charged particle in a magnetic field, the canonical momentum includes the vector potential: p=mv+qA\mathbf{p} = m\mathbf{v} + q\mathbf{A}. Always derive canonical momentum from the Lagrangian, not from mvm\mathbf{v}.

Mistake 3: Misapplying Poisson brackets The Poisson bracket {f,g}\{f, g\} is antisymmetric: {f,g}=−{g,f}\{f, g\} = -\{g, f\}. A common error is forgetting this sign when computing brackets of position and momentum. The fundamental brackets are {qj,pk}=δjk\{q_j, p_k\} = \delta_{jk}, {qj,qk}=0\{q_j, q_k\} = 0, and {pj,pk}=0\{p_j, p_k\} = 0. Mixing up the order changes the sign.