The math optional, made finite. Daily Practice

Hamilton’s equations

At a Glance

Why This Chapter Matters

Hamilton’s equations appear in 8 of the last 13 years and are the most commonly 10-mark questions in Paper 2 Section B — meaning they reward quick, clean execution. The method is a fixed procedure: write the Lagrangian, form momenta, do the Legendre transform to get HH, write the four canonical equations. The same five-step skeleton works for pendulums, rolling bodies, central-force problems, and abstract algebraic Hamiltonians. A student who practises this once per physical setup can reliably collect 10 marks per appearance.

Minimum Theory

Hamiltonian. Given a Lagrangian L(q,q˙,t)L(q,\dot q,t), the generalised momentum is pk=L/q˙kp_k=\partial L/\partial\dot q_k. The Hamiltonian is H(q,p,t)=kpkq˙kL,H(q,p,t)=\sum_k p_k\dot q_k-L, where q˙k\dot q_k is expressed in terms of pkp_k by inverting pk=L/q˙kp_k=\partial L/\partial\dot q_k.

For natural systems (holonomic time-independent constraints, VV independent of velocities): H=T+VH=T+V expressed in (q,p)(q,p) — the total mechanical energy.

Hamilton’s canonical equations: q˙k=Hpk,p˙k=Hqk.\dot q_k=\frac{\partial H}{\partial p_k},\qquad \dot p_k=-\frac{\partial H}{\partial q_k}.

Conservation laws. (1) If H/t=0\partial H/\partial t=0 (no explicit time dependence), then dH/dt=0dH/dt=0 — energy conserved. (2) If H/qk=0\partial H/\partial q_k=0 (qkq_k cyclic), then p˙k=0\dot p_k=0 — momentum pkp_k conserved.

Legendre transform for cross-coupled LL. When LL has cross terms x˙y˙\dot x\dot y, compute both momenta px=L/x˙p_x=\partial L/\partial\dot x and py=L/y˙p_y=\partial L/\partial\dot y, solve for x˙,y˙\dot x,\dot y, substitute into H=pxx˙+pyy˙LH=p_x\dot x+p_y\dot y-L.

Question Archetypes

Three patterns cover all Hamilton’s equations questions.

ArchetypeYou are seeing this when…
hamilton-eomform HH, write the canonical equations, find acceleration or a conserved quantity
hamilton-jacobifind Hamilton’s principal function SS satisfying S/t+H(S)=0\partial S/\partial t+H(\nabla S)=0
lagrangian-from-hamiltoniangiven HH, recover LL via Legendre transform

hamilton-eom (8 question(s); 2014, 2015, 2018, 2019, 2020, 2023, 2025)

Recognition Cues

Solution Template

  1. Write TT (fold in any holonomic rolling/constraint before forming momenta).
  2. Write VV; form L=TVL=T-V.
  3. Compute pk=L/q˙kp_k=\partial L/\partial\dot q_k; solve for q˙k\dot q_k in terms of pkp_k.
  4. Form H=T+VH=T+V in (q,p)(q,p) (for natural systems) or use H=pkq˙kLH=\sum p_k\dot q_k-L.
  5. Write the 2n2n canonical equations. Identify any cyclic coordinates (conserved momenta).
  6. Combine p˙=f(q)\dot p=f(q) and p=gq˙p=g\dot q to get second-order EOM if asked.

Worked Example(s)

2014 Paper 2, 2014-P2-Q5e (10 marks)

Find the equation of motion of a compound pendulum via Hamilton’s equations.

Setup. Mass MM, moment of inertia II about pivot, CG distance hh.

T=12Iθ˙2T=\frac12I\dot\theta^2, V=MghcosθV=-Mgh\cos\theta. p=Iθ˙θ˙=p/Ip=I\dot\theta\Rightarrow\dot\theta=p/I.

H=p22IMghcosθ.H=\frac{p^2}{2I}-Mgh\cos\theta.

Hamilton’s equations: θ˙=p/I\dot\theta=p/I, p˙=Mghsinθ\dot p=-Mgh\sin\theta.

Combine: Iθ¨=MghsinθI\ddot\theta=-Mgh\sin\theta.

  θ¨+MghIsinθ=0;T=2πIMgh.  \boxed{\;\ddot\theta+\frac{Mgh}{I}\sin\theta=0;\quad T=2\pi\sqrt{\frac{I}{Mgh}}.\;}


2015 Paper 2, 2015-P2-Q6b (15 marks)

Solve the plane pendulum via Hamiltonian; show HH is conserved.

T=12ml2θ˙2T=\frac12ml^2\dot\theta^2, V=mglcosθV=-mgl\cos\theta. pθ=ml2θ˙p_\theta=ml^2\dot\theta.

H=pθ22ml2mglcosθ.H=\frac{p_\theta^2}{2ml^2}-mgl\cos\theta.

HH conserved: dH/dt=Hθθ˙+Hpθp˙θdH/dt=\frac{\partial H}{\partial\theta}\dot\theta+\frac{\partial H}{\partial p_\theta}\dot p_\theta. Substituting θ˙=H/pθ\dot\theta=\partial H/\partial p_\theta and p˙θ=H/θ\dot p_\theta=-\partial H/\partial\theta: the two terms cancel.

  dHdt=0(H/t=0).  \boxed{\;\frac{dH}{dt}=0\quad(\partial H/\partial t=0).\;}


2019 Paper 2, 2019-P2-Q7a (15 marks)

Hamilton’s equations for a sphere rolling down a rough incline; find acceleration.

Fold the constraint ϕ˙=x˙/r\dot\phi=\dot x/r into TT: T=12Mx˙2+12(25Mr2)(x˙/r)2=710Mx˙2T=\frac12M\dot x^2+\frac12(\frac25Mr^2)(\dot x/r)^2=\frac{7}{10}M\dot x^2.

p=75Mx˙p=\frac75M\dot x, so H=5p214MMgxsinθH=\frac{5p^2}{14M}-Mgx\sin\theta.

x˙=5p/(7M)\dot x=5p/(7M), p˙=Mgsinθ\dot p=Mg\sin\theta.

x¨=5p˙7M=57gsinθ.  x¨=57gsinθ.  \ddot x=\frac{5\dot p}{7M}=\frac57g\sin\theta.\qquad\boxed{\;\ddot x=\frac57g\sin\theta.\;}


2020 Paper 2, 2020-P2-Q6c (20 marks)

Hamiltonian for mass mm on cylinder x2+y2=R2x^2+y^2=R^2 under force F=kr\vec F=-k\vec r.

Cylindrical coords (θ,z)(\theta,z): T=12m(R2θ˙2+z˙2)T=\frac12m(R^2\dot\theta^2+\dot z^2), V=12k(R2+z2)V=\frac12k(R^2+z^2).

pθ=mR2θ˙p_\theta=mR^2\dot\theta, pz=mz˙p_z=m\dot z.

H=pθ22mR2+pz22m+12k(R2+z2).H=\frac{p_\theta^2}{2mR^2}+\frac{p_z^2}{2m}+\frac12k(R^2+z^2).

θ\theta is cyclic: p˙θ=0pθ=\dot p_\theta=0\Rightarrow p_\theta= const (uniform rotation). Axial: p˙z=kzmz¨=kz\dot p_z=-kz\Rightarrow m\ddot z=-kz (SHM, ω=k/m\omega=\sqrt{k/m}).

  Helical oscillation: uniform rotation + axial SHM at ω=k/m.  \boxed{\;\text{Helical oscillation: uniform rotation }+\text{ axial SHM at }\omega=\sqrt{k/m}.\;}


2018 Paper 2, 2018-P2-Q7c (20 marks)

H=p1q1aq12+bq22p2q2H=p_1q_1-aq_1^2+bq_2^2-p_2q_2. Solve Hamilton’s equations; show (p2bq2)/q1=(p_2-bq_2)/q_1= const.

q˙1=q1\dot q_1=q_1, q˙2=q2\dot q_2=-q_2, p˙1=2aq1p1\dot p_1=2aq_1-p_1, p˙2=p22bq2\dot p_2=p_2-2bq_2.

q1=Aetq_1=Ae^t, q2=Betq_2=Be^{-t}; p2=Cet+bBetp_2=Ce^t+bBe^{-t}.

p2bq2=Cet    p2bq2q1=CetAet=CA=const.p_2-bq_2=Ce^t\;\Longrightarrow\;\frac{p_2-bq_2}{q_1}=\frac{Ce^t}{Ae^t}=\frac CA=\text{const}.

Shortcut: w˙=w\dot w=w where w=p2bq2w=p_2-bq_2 (same as q˙1=q1\dot q_1=q_1) ⇒ w/q1w/q_1 is a constant of motion.

  p2bq2q1=const.  \boxed{\;\frac{p_2-bq_2}{q_1}=\text{const}.\;}


2023 Paper 2, 2023-P2-Q5d (10 marks)

Planet of mass mm; T=12m(r˙2+r2θ˙2)T=\frac12m(\dot r^2+r^2\dot\theta^2), V=GMm(1/2a1/r)V=GMm(1/2a-1/r). Find HH and Hamilton’s equations.

pr=mr˙p_r=m\dot r, pθ=mr2θ˙p_\theta=mr^2\dot\theta.

H=pr22m+pθ22mr2+GMm ⁣(12a1r).H=\frac{p_r^2}{2m}+\frac{p_\theta^2}{2mr^2}+GMm\!\left(\frac{1}{2a}-\frac1r\right).

p˙θ=0\dot p_\theta=0 (θ\theta cyclic — angular momentum conserved). p˙r=pθ2/(mr3)GMm/r2\dot p_r=p_\theta^2/(mr^3)-GMm/r^2.

  r˙=prm,θ˙=pθmr2,p˙r=pθ2mr3GMmr2,p˙θ=0.  \boxed{\;\dot r=\frac{p_r}m,\quad\dot\theta=\frac{p_\theta}{mr^2},\quad\dot p_r=\frac{p_\theta^2}{mr^3}-\frac{GMm}{r^2},\quad\dot p_\theta=0.\;}


2025 Paper 2, 2025-P2-Q8c-i (10 marks)

V=kcosθ/r2V=-k\cos\theta/r^2. Find HH and Hamilton’s equations in spherical polars (r,θ,ϕ)(r,\theta,\phi).

T=12m(r˙2+r2θ˙2+r2sin2θϕ˙2)T=\frac12m(\dot r^2+r^2\dot\theta^2+r^2\sin^2\theta\dot\phi^2). Momenta: pr=mr˙p_r=m\dot r, pθ=mr2θ˙p_\theta=mr^2\dot\theta, pϕ=mr2sin2θϕ˙p_\phi=mr^2\sin^2\theta\dot\phi.

H=pr22m+pθ22mr2+pϕ22mr2sin2θkcosθr2.H=\frac{p_r^2}{2m}+\frac{p_\theta^2}{2mr^2}+\frac{p_\phi^2}{2mr^2\sin^2\theta}-\frac{k\cos\theta}{r^2}.

ϕ\phi is cyclic: p˙ϕ=0\dot p_\phi=0. Key derivatives: p˙r=pθ2/(mr3)+pϕ2/(mr3sin2θ)2kcosθ/r3\dot p_r=p_\theta^2/(mr^3)+p_\phi^2/(mr^3\sin^2\theta)-2k\cos\theta/r^3; p˙θ=pϕ2cosθ/(mr2sin3θ)ksinθ/r2\dot p_\theta=p_\phi^2\cos\theta/(mr^2\sin^3\theta)-k\sin\theta/r^2.


2025 Paper 2, 2025-P2-Q8c-ii (10 marks)

L=mx˙y˙mω02xyL=m\dot x\dot y-m\omega_0^2xy. Find HH and Hamilton’s equations; identify the system.

Cross-coupled momenta: px=my˙p_x=m\dot y, py=mx˙p_y=m\dot x. Invert: x˙=py/m\dot x=p_y/m, y˙=px/m\dot y=p_x/m.

H=pxx˙+pyy˙L=pxpy/m+mω02xymx˙y˙+mω02xyH=p_x\dot x+p_y\dot y-L=p_xp_y/m+m\omega_0^2xy-m\dot x\dot y+m\omega_0^2xy. After substituting mx˙y˙=pxpy/mm\dot x\dot y=p_xp_y/m:

H=pxpym+mω02xy.H=\frac{p_xp_y}{m}+m\omega_0^2xy.

p˙x=mω02y\dot p_x=-m\omega_0^2y, p˙y=mω02x\dot p_y=-m\omega_0^2x. Combining: x¨=ω02x\ddot x=-\omega_0^2x, y¨=ω02y\ddot y=-\omega_0^2y.

  Two independent SHMs at ω0.  \boxed{\;\text{Two independent SHMs at }\omega_0.\;}

Common Traps


hamilton-jacobi (1 question(s); 2016)

Recognition Cues

Solution Template

Hamilton’s principal function S=S= action along the actual trajectory. For a free particle with constant velocity x˙i=xi/τ\dot x_i=x_i/\tau: integrate L=TL=T over [0,τ][0,\tau].

Worked Example(s)

2016 Paper 2, 2016-P2-Q5c (10 marks)

Free particle, mass mm, from origin to (x,y,z)(x,y,z) in time τ\tau. Find Hamilton’s characteristic function SS.

Constant-velocity motion: x˙i=xi/τ\dot x_i=x_i/\tau. Integrand constant in time: S=0τ12mr2τ2dt=mr22τ,r2=x2+y2+z2.S=\int_0^\tau\tfrac12m\frac{r^2}{\tau^2}\,dt=\frac{mr^2}{2\tau},\quad r^2=x^2+y^2+z^2.

  S=m(x2+y2+z2)2τ.  \boxed{\;S=\frac{m(x^2+y^2+z^2)}{2\tau}.\;}

Verify: S/τ=mr2/(2τ2)=H\partial S/\partial\tau=-mr^2/(2\tau^2)=-H; 12mS2=mr22τ2=H\frac1{2m}|\nabla S|^2=\frac{m r^2}{2\tau^2}=H ✓.


lagrangian-from-hamiltonian (1 question(s); 2015)

Recognition Cues

Worked Example(s)

2015 Paper 2, 2015-P2-Q7c-i (10 marks)

H=p22αbqpeαt+bα2q2eαt(α+beαt)+k2q2H=\frac{p^2}{2\alpha}-bqpe^{-\alpha t}+\frac{b\alpha}{2}q^2e^{-\alpha t}(\alpha+be^{-\alpha t})+\frac k2q^2. Find LL.

q˙=H/p=p/αbqeαtp=α(q˙+bqeαt)\dot q=\partial H/\partial p=p/\alpha-bqe^{-\alpha t}\Rightarrow p=\alpha(\dot q+bqe^{-\alpha t}).

Substitute into L=pq˙HL=p\dot q-H; the bqeαtbqe^{-\alpha t} cross terms and e2αte^{-2\alpha t} terms all cancel:

  L=α2q˙2+αbqq˙eαtbα2q2eαt2kq22.  \boxed{\;L=\frac\alpha2\dot q^2+\alpha bq\dot q e^{-\alpha t}-\frac{b\alpha^2q^2e^{-\alpha t}}{2}-\frac{kq^2}{2}.\;}

(Adding dF/dtdF/dt with F=αbq2eαt/2F=-\alpha bq^2e^{-\alpha t}/2 reduces this to the SHM Lagrangian α2q˙2k2q2\frac\alpha2\dot q^2-\frac k2q^2 — see MF-03 gauge-lagrangian.)


Marks-Aware Writing

10-mark questions (2014, 2016, 2023, 2025): Write TT and VV (one line each), form pkp_k and HH (two lines), state all canonical equations (four lines), identify cyclic coordinates. Box the answer.

15-mark questions (2015, 2019): For the rolling sphere: show the constraint fold explicitly (I/Mr2I/Mr^2 factor), state the effective mass in HH, derive the acceleration. For the pendulum: also write the conservation proof dH/dt=0dH/dt=0 step by step.

20-mark questions (2018, 2020): Solve all four ODEs (show integrating factor for the pp equations); for the invariant proof show either the explicit cancellation or the shortcut w˙/w=q˙1/q1\dot w/w=\dot q_1/q_1.

Practice Set

YearPaper/QMarksArchetypeOne-line hint
2025P2-Q8c-i10hamilton-eomv2v^2 in spherical coords; ϕ\phi cyclic; p˙r\dot p_r picks up centrifugal +pθ2/(mr3)+p_\theta^2/(mr^3)
2025P2-Q8c-ii10hamilton-eompx=my˙p_x=m\dot y, py=mx˙p_y=m\dot x (swapped!); H=pxpy/m+mω02xyH=p_xp_y/m+m\omega_0^2xy; x¨=ω02x\ddot x=-\omega_0^2x
2023P2-Q5d10hamilton-eompθ=mr2θ˙p_\theta=mr^2\dot\theta; θ\theta cyclic; p˙r=pθ2/(mr3)GMm/r2\dot p_r=p_\theta^2/(mr^3)-GMm/r^2
2020P2-Q6c20hamilton-eom(θ,z)(\theta,z) coords; θ\theta cyclic → uniform rotation; axial SHM ω=k/m\omega=\sqrt{k/m}
2019P2-Q7a15hamilton-eomFold rolling: T=710Mx˙2T=\frac7{10}M\dot x^2; p=75Mx˙p=\frac75M\dot x; x¨=57gsinθ\ddot x=\frac57g\sin\theta
2018P2-Q7c20hamilton-eomq1=Aetq_1=Ae^t, q2=Betq_2=Be^{-t}; p2p_2 particular part =bq2=bq_2; ratio C/AC/A is constant
2016P2-Q5c10hamilton-jacobiFree particle: straight-line x˙i=xi/τ\dot x_i=x_i/\tau; S=Ldt=mr2/(2τ)S=\int L\,dt=mr^2/(2\tau)
2015P2-Q6b15hamilton-eompθ=ml2θ˙p_\theta=ml^2\dot\theta; dH/dt=0dH/dt=0 from H/t=0\partial H/\partial t=0; pendulum EOM
2015P2-Q7c-i10lagrangian-from-hamiltonianq˙=p/αbqeαt\dot q=p/\alpha-bqe^{-\alpha t}; multiple cancellations; result has eαte^{-\alpha t} time dep
2014P2-Q5e10hamilton-eomH=p2/(2I)MghcosθH=p^2/(2I)-Mgh\cos\theta; combine p˙=Mghsinθ\dot p=-Mgh\sin\theta with p=Iθ˙p=I\dot\theta

We've mapped all 13 years of this exam. Get new chapters, tools, and solutions as we release them — free.