Hamiltonian Mechanics
One more reformulation, and it is the one quantum mechanics actually quantizes. Trading velocity for momentum turns second-order equations into first-order ones, makes "the state of the system" a single point in phase space — and equips observables with an algebraic operation, the Poisson bracket, which is precisely the commutator of Term 1 wearing classical fur.
Learning Objectives
After this lesson you will be able to:
- Compute Legendre transforms and construct the Hamiltonian from a Lagrangian.
- Derive and apply Hamilton's equations, and judge when and when equals the energy.
- Analyze motion in phase space: flow, non-crossing trajectories, oscillator ellipses, and the pendulum separatrix.
- Compute Poisson brackets, exploit their algebraic properties, and evaluate the fundamental brackets.
- Write time evolution as and detect conserved quantities via .
- State Dirac's canonical quantization rule and map to .
- Include non-conservative forces through generalized forces, , and account for every change of the Hamiltonian, .
Intuition
The Lagrangian lives on positions and velocities; to know where the system goes you still must solve second-order equations. Hamilton's move is to promote the momentum to an independent variable. The payoff is conceptual as much as computational: the complete state of the system becomes a single point in phase space, and dynamics becomes a flow — every point knows exactly where it is going next. On top of this geometry sits an algebra: the Poisson bracket combines any two observables into a third, and time evolution, conservation laws, and symmetries are all statements about brackets. Quantum mechanics keeps the entire structure and changes one thing: the bracket becomes a commutator, with setting the exchange rate.
Theory
The Legendre transform
For a convex function (i.e. ), the Legendre transform is
Since is strictly increasing, is well defined. Geometric meaning: the tangent to at has slope and -intercept , so re-encodes the curve by its family of tangent lines — slope in, intercept out, no information lost. It is involutive: , so transforming returns . Worked scalar example: gives , , and — the shape of every kinetic term to come.
Canonical momentum and the Hamiltonian
Define the canonical momentum conjugate to by (for this is , but not always — recall the magnetic Lagrangian from P.1.3). The Hamiltonian is the Legendre transform of in its velocity slots:
with every eliminated in favor of by inverting .
Hamilton's equations
Take the differential of as defined above:
The terms cancel by the definition of — this is what the Legendre transform is for. Along an actual motion, Euler–Lagrange gives , so . Comparing coefficients with :
Hamilton's equations: first-order equations replacing second-order ones. Oscillator check: gives , — Newton again.
When is ? When is the energy?
Two independent facts. (i) If the map from Cartesian to generalized coordinates has no explicit time dependence, is a homogeneous quadratic ; Euler's theorem for homogeneous functions then gives . With velocity-independent, , so and . (ii) Independently, (proved below), so is conserved exactly when it has no explicit time dependence. All four combinations occur: the bead on a rotating wire (Worked Example 2) has conserved yet , because the rotating constraint makes the coordinate map time-dependent.
Caution. whenever constraints (or the coordinates) are time-dependent — do not read "the Hamiltonian" reflexively as "the energy". And beware a notational ambush ahead: in this program is the Hamiltonian here, but the Hadamard gate in quantum-circuit contexts — Appendix C flags the clash. Context decides.
Non-conservative forces: how leaks
Everything so far assumed that every force lives inside . Friction, drag and external pushes that derive from no potential enter instead through the generalized forces of P.1.3: keep the conservative part in and collect the rest in . Lagrange's equations become , and repeating the derivation with gives
Feed these into the chain rule:
A Hamiltonian can change for exactly two reasons: it depends on time explicitly, or non-conservative forces deliver power . When , the second term is the rate at which those forces do work, the work–energy theorem in generalized coordinates. Example: a damped oscillator with drag has , so , and the energy drains at exactly the rate drag does work. Linear drag is common enough to have a shorthand: with Rayleigh's dissipation function , and ([Gold] §1.5). The same drag, written with , is what shrinks phase-space areas in the Liouville paragraph below. A driving force can be booked either way, as a or as a time-dependent potential; E6 shows the two bookkeepings agree.
Phase space
The state of the system is the point — phase space. Hamilton's equations attach a velocity vector to every point, defining a flow; by uniqueness of ODE solutions, exactly one trajectory passes through each point, so trajectories never cross. For the oscillator, traces an ellipse with semi-axes and , of area
Phase-space area carries units of action (J·s). The old quantum theory (P.2.3) will quantize exactly this area in units of Planck's constant — nature slices phase space into cells of size .
Area is also what the flow itself respects. Follow not one state but a small region of them: the flow may stretch and fold it, yet its area never changes. This is Liouville's theorem — in dimensions, the flow preserves phase-space volume, so a density of states carried along is constant. The reason is that the velocity field has zero divergence, . Friction adds to , the divergence becomes , and areas shrink as .
Interactive demo: A blob of states in phase space. Let the pendulum’s flow shear a disk of initial conditions into filaments: its shape goes, its area stays (Liouville).
Poisson brackets
For two observables , define the Poisson bracket
Its algebra: antisymmetry (swap the two terms) and bilinearity in each slot (derivatives are linear) are immediate. The Leibniz/product rule follows by direct computation: since (same for ),
Finally the Jacobi identity holds (a patient expansion of second derivatives; you verify an instance in E4). The fundamental brackets follow from etc.:
Time evolution is a bracket
Let be any observable, evaluated along a trajectory. Chain rule plus Hamilton's equations:
The Hamiltonian generates time evolution. Special cases: and reproduce Hamilton's equations; (antisymmetry kills ), proving the conservation claim above. And for any time-independent observable,
The angular momentum algebra
With : , , . Compute by summing over ; the only nonvanishing partials of are , , , , and of : , , , . Term by term (-, -, -slots):
Cyclically, and (E5). This closed algebra — computed here with nothing but calculus — will single-handedly determine the quantum theory of angular momentum in P.6.1.
Dirac's rule: the classical shadow of the commutator
Here is the headline. In 1925 Dirac observed that the Poisson bracket's algebra — antisymmetry, bilinearity, Leibniz rule, Jacobi identity — is exactly the algebra of the operator commutator . Canonical quantization promotes phase-space functions to operators and postulates the correspondence
The consequences land one for one. The fundamental bracket becomes the canonical commutation relation — the single equation from which position–momentum uncertainty follows via the Robertson relation (1.3.2). The evolution law becomes , equivalently — the Evolution Postulate (1.1.3), with the Hamiltonian still the generator of time translation. And becomes , fixing the entire quantum angular momentum spectrum before any differential equation is solved. The Poisson bracket is the classical shadow of the commutator: everything you computed in this lesson survives quantization with , and classical mechanics is recovered as the limit of the commutator algebra.
Worked Examples
Example 1 — The oscillator in phase space, with numbers
A mass kg on a spring N/m: rad/s. Legendre: , so (here : time-independent everything). At J the trajectory is the ellipse with m and kg·m/s, traversed clockwise once per period s. Enclosed area: J·s ✓ — energy and enclosed action are proportional, with the conversion factor.
Example 2 — conserved, yet not the energy
The bead on a wire rotating at constant (P.1.3, Example 2): , so and
No explicit , so is conserved. But the energy is , which grows as the bead flies outward — the motor does work. The culprit: the time-dependent constraint makes non-homogeneous in (it has a velocity-independent piece ), so the Euler's-theorem step fails and . Conserved Hamiltonian, non-conserved energy — the two notions genuinely split. Both, plotted for the running bead:
Interactive demo: Conserved, but not the energy. Spin a wire with a bead on it: the Hamiltonian stays constant while the energy climbs, because the motor does work.
Example 3 — A central force in phase space
A particle of mass moves in a plane under a central potential . From the Lagrangian of P.1.3, , the canonical momenta are and , so and . The Legendre transform gives
which is , as it must be for a scleronomic system. Hamilton's four equations:
The last says is cyclic and , the angular momentum, is a constant. Fix its value and the radial pair is a one-dimensional problem with
the effective potential: the true potential plus a repulsive centrifugal barrier. Circular orbits sit where , at the minimum of . For the attractive Coulomb potential that means , i.e. . Put in hydrogen's and an angular momentum of one , and Å: Bohr's first orbit (P.2.2) is the bottom of this well. The same reduction returns in quantum mechanics as the radial equation of P.6.2, where the barrier becomes .
Hands-on (Python)
import numpy as np
import matplotlib.pyplot as plt
# --- Phase portraits: oscillator ellipses and the pendulum separatrix ---
m, ell, g = 1.0, 1.0, 9.81
w = np.sqrt(g/ell)
fig, ax = plt.subplots(1, 2, figsize=(11, 4))
q, p = np.meshgrid(np.linspace(-2, 2, 300), np.linspace(-2, 2, 300))
ax[0].contour(q, p, p**2/(2*m) + 0.5*m*w**2*q**2, levels=10)
ax[0].set(title="Oscillator: H contours are ellipses", xlabel="q", ylabel="p")
th, pth = np.meshgrid(np.linspace(-2*np.pi, 2*np.pi, 600), np.linspace(-8, 8, 400))
H_pen = pth**2/(2*m*ell**2) - m*g*ell*np.cos(th)
ax[1].contour(th, pth, H_pen, levels=20)
ax[1].contour(th, pth, H_pen, levels=[m*g*ell], colors="r", linewidths=2)
ax[1].set(title="Pendulum: red = separatrix (E = mgl)", xlabel="theta", ylabel="p")
plt.tight_layout(); plt.show()
# Expected: nested ellipses (left). Right: closed curves (libration) inside the
# red separatrix through (+-pi, 0), open wavy curves (full rotation) outside --
# the separatrix is the trajectory that takes infinite time to reach the top.import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
# --- Energy drift over 100 periods: explicit vs symplectic Euler vs RK45 ---
# Oscillator with m = w = 1, (q0, p0) = (1, 0), E0 = 1/2.
dt = 0.05
steps = int(100*2*np.pi/dt)
E = lambda q, p: 0.5*(p**2 + q**2)
q_e = np.empty(steps + 1); p_e = q_e.copy(); q_e[0], p_e[0] = 1.0, 0.0
q_s = q_e.copy(); p_s = p_e.copy()
for i in range(steps):
# explicit Euler: both updates from the OLD state
q_e[i+1] = q_e[i] + dt*p_e[i]; p_e[i+1] = p_e[i] - dt*q_e[i]
# symplectic Euler: momentum first, then position with the NEW momentum
p_s[i+1] = p_s[i] - dt*q_s[i]; q_s[i+1] = q_s[i] + dt*p_s[i+1]
t = np.arange(steps + 1)*dt
sol = solve_ivp(lambda t, y: [y[1], -y[0]], (0, t[-1]), [1.0, 0.0],
t_eval=t, rtol=1e-8, atol=1e-10) # RK45 by default
for qq, pp, lab in [(q_e, p_e, "explicit Euler"), (q_s, p_s, "symplectic Euler"),
(sol.y[0], sol.y[1], "RK45")]:
plt.semilogy(t, np.abs(E(qq, pp)/0.5 - 1) + 1e-16, label=lab)
plt.xlabel("t"); plt.ylabel("|E/E0 - 1|"); plt.legend(); plt.show()
# Expected: explicit Euler's energy error grows EXPONENTIALLY (each step
# multiplies E by 1 + dt^2); symplectic Euler's stays bounded ~ dt forever;
# RK45 is tiny but drifts secularly. The symplectic update respects the
# phase-space (bracket) structure -- geometry beats raw accuracy.Exercises
E1 (easy). Compute the Legendre transform of (, ).
Solution
. Then . Check: ✓ (the involution property).
E2 (easy). Construct for a projectile, , write Hamilton's equations, and identify the conserved momentum.
Solution
, , so . Equations: , , , . Since is absent from , is conserved — equivalently .
E3 (medium). For a central potential, . Show and interpret.
Solution
. All partials of vanish except , leaving since is absent from . Angular momentum is conserved because the Hamiltonian is rotationally symmetric — the bracket version of the cyclic-coordinate argument, and the classical seed of in P.6.1.
E4 (medium). Verify the Jacobi identity for , , (one particle, 1D).
Solution
Inner brackets: ; ; . Then ; ; . Sum: ✓.
E5 (hard). Show and , then prove for . What does this mean physically?
Solution
The theory computation gave ; the relabeling maps 's components into each other and leaves the bracket's structure invariant, so and (or repeat the six-term computation). Compactly, . By Leibniz and antisymmetry: , , and ; the sum vanishes. So is invariant under the rotations any generates: the magnitude of angular momentum is compatible with any one component. Quantum translation: , which is why states carry the simultaneous quantum numbers and (P.6.1).
E6 (medium). A damped oscillator is driven by an external force: . (a) Keep only the spring in and treat drag and drive as generalized forces; with , find . (b) Now put the drive into the Lagrangian as the time-dependent potential , keeping only drag as a generalized force. Find the new Hamiltonian and . Reconcile (a) and (b).
Solution
(a) and , so : drag drains energy, the drive feeds it. (b) , , so . Now and , giving . Reconcile by differentiating directly: , and substituting (a) gives (b) ✓. The motion is identical; only the bookkeeping differs. is the oscillator's own energy, while also contains its interaction energy with the driver, which changes because the driver's potential depends on time.
Checkpoint
- Define the Legendre transform and give its geometric meaning.
- Derive Hamilton's equations from : which terms cancel by construction, and where is Euler–Lagrange used?
- State the separate conditions for and for conserved, with an example where they come apart.
- List the four algebraic properties of the Poisson bracket and the fundamental brackets.
- State Dirac's quantization rule. What do and become?
- Name the two ways a Hamiltonian can change in time, and say what the second one means physically.
Answers
- with ; it describes the convex curve by its tangent lines (slope intercept), losing no information, and is involutive.
- In the terms cancel because ; Euler–Lagrange converts to ; matching coefficients of gives , .
- needs a time-independent coordinate map (so is homogeneous quadratic) and velocity-independent ; is conserved iff . Bead on a rotating wire: conserved but .
- Antisymmetry, bilinearity, Leibniz product rule, Jacobi identity; , .
- . Then , and — quantum time evolution, equivalently (1.1.3).
- : explicit time dependence, and power delivered by non-conservative generalized forces. When the second term is the work–energy theorem: energy changes exactly by the work friction, drag or a drive does.
Further Reading
- [Gold] Goldstein, Poole & Safko, Ch. 8 and §9.5 — Hamilton's equations; Poisson brackets and canonical invariants.
- [Sha] Shankar, Ch. 2 — the Hamiltonian formulation, compact and aimed squarely at quantization.
- [Sak] Sakurai & Napolitano, §1.6 — canonical commutation relations and Dirac's analogy, up close.
← Prev: Lagrangian Mechanics · Up: Pre-Term · Next: Blackbody Radiation & Planck's Law →