Hamilton's Canonical Equations
In 1834 a twenty-nine-year-old Irish astronomer, already famous for predicting a new optical phenomenon from pure mathematics, published a paper that rebuilt all of mechanics around a single scalar function. William Rowan Hamilton's idea looks almost too simple: trade each velocity for its conjugate momentum via a Legendre transformation, and the second-order Lagrange equations split into first-order ones of hypnotic symmetry — , . One function, , generates every trajectory of the system. What the reformulation buys is not computational convenience — for a bead on a wire, Lagrange is usually faster — but geometry. The state of a system becomes a single point in a -dimensional phase space; the dynamics becomes a flow, as literal as water, whose velocity field is the -rotated gradient of . Motion runs along the contour lines of the Hamiltonian landscape, which is why energy conservation is visible before any calculation. The lone minus sign in the pair of equations makes that flow exactly incompressible — Liouville's theorem — and seeds the entire symplectic structure of mechanics. This page is the gateway to the deepest classical machinery: phase portraits, Poisson brackets, canonical transformations, Hamilton–Jacobi theory, and — via Dirac's substitution of commutators for brackets — quantum mechanics itself. It is also, very concretely, the equation set running inside every solar-system ephemeris, every molecular-dynamics engine, and every Hamiltonian Monte Carlo sampler in modern statistics.
- Hamilton's canonical equations replace the second-order Lagrange equations by first-order ones: and .
- They follow from a Legendre transform of the Lagrangian, , which trades the velocity for the conjugate momentum as the independent variable.
- The two equations divide labour: is kinematics (how coordinates move given momenta), is Newton's second law in disguise.
- Along any solution — so is conserved whenever it has no explicit time dependence.
- The minus sign makes the phase-space velocity field divergence-free: phase volume is conserved (Liouville), and the flow never crosses itself — determinism made geometric.
- Compactly: with the symplectic matrix ; equivalently for any observable .
- Key idea: a single scalar function on phase space generates all the dynamics through the antisymmetric pairing , ; the sign asymmetry is the seed of the entire symplectic structure.
Where this lives today
The longest-running computations in science are integrations of Hamilton's equations. Solar-system ephemerides and long-term stability studies (does Mercury's orbit go chaotic? — yes, with a small probability, over gigayears) rely on symplectic integrators: discrete update rules like leapfrog and its higher-order refinements that advance while exactly preserving the symplectic matrix of equation (5). Because they conserve a "shadow Hamiltonian" close to the true one, their energy error stays bounded over billions of steps instead of drifting — the practical dividend of the minus sign. The same integrators drive molecular-dynamics engines simulating proteins and materials with millions of atoms. The most surprising modern tenant of phase space is statistics. Hamiltonian Monte Carlo — the algorithm inside Stan, PyMC, and NumPyro — samples a probability distribution by inventing fictitious momenta, defining , and integrating the canonical equations with leapfrog steps. The Hamiltonian flow carries the sampler along contours of the landscape to distant, high-probability states that a random walk would take ages to reach; Liouville's theorem is what makes the acceptance rule exact. Every Bayesian model fitted this way is, quietly, a run of the equations Hamilton wrote for the planets.
The physical picture
Picture as a landscape over phase space — altitude plotted over the plane. Ordinary gradient dynamics (a ball rolling downhill, heat flowing to cold) would send the state down the slope. Hamiltonian dynamics does something stranger and more beautiful: it takes the gradient and rotates it by , so the phase point moves along the contour lines, neither gaining nor losing altitude. That single geometric move is why energy is conserved, why oscillators trace closed ellipses, and why Hamiltonian systems never "settle down" the way damped systems do — there is no downhill!
The two equations split the work cleanly. The first, , is the kinematic half: for a standard kinetic energy it just says , velocity is momentum divided by mass. The second, , is the dynamic half: when it reads , Newton's second law. Lagrange packs both statements into one second-order equation; Hamilton pulls them apart so that each is first order, and the state at one instant determines everything. The minus sign between them is not cosmetic bookkeeping — it is the whole point. It makes the phase-space velocity field divergence-free, , so the phase fluid flows like an incompressible liquid: blobs of initial conditions shear and stretch but never change volume. And because the system is first order, exactly one trajectory passes through each phase-space point — trajectories can never intersect. Determinism, energy conservation, and Liouville's theorem are all sitting in that one sign before a single problem has been solved.
From Lagrangian to Hamiltonian
The Hamiltonian is defined by the Legendre transformation of with respect to the velocities. The recipe looks innocuous, but the sum is precisely engineered so that all velocity dependence cancels out of the result:
where: — the conjugate (canonical) momentum; every on the right must be eliminated in favour of by inverting that definition. The transform swaps which variable is fundamental: answers "what happens at this velocity?", answers "what happens at this momentum?" — the same information, differently indexed, exactly as in thermodynamics when energy trades places with enthalpy or free energy.
We derive Hamilton's canonical equations (2) — and — from nothing but the Legendre definition (1) and the Euler–Lagrange equation. The strategy is to compute twice — once by differentiating the definition (1), once from the assertion that is a function of alone — and match coefficients of the independent differentials. The route works only if every term cancels along the way; that cancellation is not luck but the entire design of the Legendre transform, so watch for it in Step 2. Watch also where the physics enters: Steps 1–4 are pure bookkeeping about the transform, and actual dynamics arrives only in Step 5, when Euler–Lagrange converts into .
Step 1. Differentiate the definition and expand :
Why write everything out: the danger term is — if it survives, is not a phase-space function and the whole construction fails.
Step 2. Watch the cancellation. Since by definition, the and terms annihilate exactly:
Why this is the heart of the Legendre transform: the combination is precisely the one whose differential contains but no — so genuinely lives on phase space, not on velocity space.
Step 3. Now write as a phase-space function must look: . Why we may do this: Step 2 proved depends only on , so its differential has exactly these three kinds of terms.
Step 4. Match coefficients of the independent differentials , , :
Why matching is legal: , , are independent variables on phase space, so their differentials can be dialed separately; equal 1-forms must have equal coefficients. The first relation is already the first canonical equation — note it is pure bookkeeping, no dynamics has entered yet.
Step 5. Inject the physics. The Euler–Lagrange equation says , which converts the middle relation of Step 4 into the second canonical equation. Together:
where: the first equation held identically (kinematics of the transform); the second is exactly where Newton's law lives. Why the minus sign appears on this one and not the other: the Legendre transform flips the sign of every variable it does not trade — stays a variable of , so its partial derivative inherits . Two immediate corollaries are one line each, and both are load-bearing. First, take the total time derivative of along a solution and insert (2):
where: the bracket cancels identically — the rotation at work: the flow is orthogonal to the gradient, so changes only through explicit time dependence. Autonomous Hamiltonian, conserved Hamiltonian: no exceptions. Second, the same cancellation for an arbitrary observable does not vanish but organizes itself into the Poisson bracket:
where: — the Poisson bracket. Equation (4) says generates time evolution of everything: constants of motion are exactly the observables that Poisson-commute with . Replace by and this becomes Heisenberg's equation of motion — the shortest road from this page to quantum mechanics.
The geometry in matrix form
Stack the coordinates into and both equations become one:
where: — the standard symplectic matrix, with and . is the rotation of the physical picture, promoted to dimensions; every deep structural fact of mechanics (canonical transformations, Liouville, integral invariants) is a statement about transformations that preserve . The divergence-free property is now one line:
where: equality of mixed partials does all the work. This is Liouville's theorem in differential form: the phase fluid is incompressible, whatever is. For the workhorse case — kinetic energy quadratic in velocities, , potential independent of velocity — the momentum–velocity relation inverts to , and Euler's theorem for homogeneous quadratics gives , so :
where: — the mass/inertia matrix. In this standard situation the Hamiltonian is the total energy — but treat that as a theorem with hypotheses, not an identity: rotating frames, time-dependent constraints, and velocity-dependent potentials all break it.
Go deeper · Derivation B · 1 minThe same equations from a variational principle
We now re-derive the canonical equations (2) by a second, deeper route: Hamilton's principle recast on phase space, extremizing the action with and varied independently. That independence is the formal expression of their equal status — and the payoff of this route is that it never mentions the Lagrangian's velocity space, so phase space stands on its own feet. The mechanics of the proof is short: one integration by parts, then read off the coefficients of and separately. The subtlety to watch is the boundary term: only is pinned at the endpoints, while needs no boundary condition at all — an asymmetry easy to gloss over here that becomes load-bearing in Hamilton–Jacobi theory.
Step 1. Extremize the phase-space action over independent variations , :
Why the integrand is : by (1) this is just rewritten in phase-space variables — the same action as always, but with twice as many independent functions to wiggle.
Step 2. Integrate the term by parts: . Why the boundary term dies: only is pinned at the endpoints; note that no boundary condition on is needed at all — an asymmetry that matters in Hamilton–Jacobi theory.
Step 3. Collect by independent variation:
Why grouping is decisive: and are arbitrary and independent, so stationarity forces each bracket to vanish separately — there is no way to trade an error in one against the other.
Step 4. Read off both canonical equations at once: and . Why this derivation is worth having: it never mentions the Lagrangian's velocity space — phase space stands on its own feet, and the door to canonical transformations (changing wholesale while preserving the form of the equations) is now open.
Which formulation answers which question
| you want | use | why |
|---|---|---|
| equations of motion from | , , eq. (2) | the workhorse |
| build from | , eq. (1), then eliminate | Legendre recipe |
| is energy conserved? | , eq. (3) | check explicit only |
| evolution of any observable | , eq. (4) | conservation ⇔ |
| geometric/structural statements | , eq. (5) | symplectic form manifest |
| standard mechanical systems | with in momenta, eq. (7) | valid for quadratic , static constraints |
Limiting cases
| Case | Result | Meaning |
|---|---|---|
| free particle | : , | momentum conserved; phase trajectories are horizontal straight lines |
| cyclic coordinate | conjugate momentum conserved by inspection — conservation laws for free | |
| time-independent | motion confined to constant-energy surfaces in phase space | |
| harmonic oscillator | elliptical phase orbits traversed clockwise at rate | |
| relativistic free particle | : | canonical machinery unchanged; automatic since |
Worked examples
1 · A harmonic oscillator, fully solved in phase space (confidence builder)
A mass on a spring of stiffness starts at with momentum . Find the Hamiltonian, the equations of motion, the energy, and the phase-space ellipse.
Step 1. Build : with , the momentum is , so and . Natural frequency: .
Step 2. Canonical equations: and . Differentiating the first and inserting the second recovers . ✓
Step 3. Energy from the initial point: , conserved forever by (3).
Step 4. The trajectory is the ellipse with semi-axes and , traversed clockwise with period .
Step 5. Bonus check with an eye on action-angle variables: the enclosed phase area is , which equals . ✓ Phase-space area divided by is the action variable — the quantity old quantum theory would later force to be an integer times .
2 · A satellite orbit by cyclic coordinates (exam level)
A satellite of mass moves in Earth's field, with . Using polar coordinates in the orbital plane, find , identify the conserved quantities, and use the canonical equations to find the speed and period of a circular orbit at .
Step 1. From , the momenta are and . Eliminating velocities:
Step 2. Spot the structure before computing. has no explicit : energy is conserved. has no : the coordinate is cyclic, so and the angular momentum is a constant — Kepler's second law read off in one line, no vector products needed.
Step 3. Write the radial canonical equations: and . A circular orbit means forever, so we need : the centrifugal term must balance gravity.
Step 4. Solve the balance: , i.e. .
Step 5. Period: — the familiar low-Earth-orbit hour-and-a-half. The conserved momentum itself: .
Step 6. The moral: the canonical formalism converted a two-dimensional orbit problem into one effective radial equation plus a conservation law harvested by inspection. That "cyclic coordinate ⇒ frozen momentum" reflex is the everyday superpower of Hamiltonian mechanics — and the seed of the action-angle method that follows it.
Origins · 1 minWilliam Rowan Hamilton and how this was discovered
Hamilton was appointed Astronomer Royal of Ireland at 22, while still an undergraduate, on the strength of a paper treating optics as a variational theory. His "theory of systems of rays" predicted conical refraction in biaxial crystals — light exiting as a hollow cone — which was confirmed within months and made him famous across Europe. The two great dynamics papers of 1834–35 transplanted the same variational machinery from light rays to particle trajectories, introducing the characteristic function, the canonical equations, and the phrase "principle of varying action". A decade later, walking along the Royal Canal in Dublin, he saw in a flash how to multiply quadruples — and carved the quaternion relations into the stone of Broom Bridge. He regarded quaternions as his masterpiece; posterity chose the equations on this page, which turned out to be the exact classical skeleton on which quantum mechanics was later hung.
Going further
Texts. Goldstein, Poole & Safko, Classical Mechanics, 3rd ed., Ch. 8 · Landau & Lifshitz, Mechanics, §40 · Morin, Introduction to Classical Mechanics, Ch. 15 · Taylor, Classical Mechanics, Ch. 13 · Arnold, Mathematical Methods of Classical Mechanics, Ch. 3. Key self-consistency checks: the differential-comparison derivation yields and ; follows from the chain rule combined with the canonical equations; the divergence of vanishes by equality of mixed partials. The harmonic-oscillator phase ellipse has semi-axes in and in . Worked-example values ( rad/s, J, enclosed area J·s; km/s, min for the km orbit with ) all follow directly from the boxed formulas.
Builds on: The Hamiltonian Function · Legendre Transformation · Generalized Momenta · Phase Space. Leads to: Hamiltonian Flow and the Phase Fluid · Phase Portraits and Trajectories · Liouville's Theorem · Equivalence of Lagrangian and Hamiltonian Formulations.
If Lagrangian mechanics already solves every problem, what does Hamilton actually buy me?
For a bead on a wire, honestly, almost nothing — Lagrange is usually faster, and the article says so up front. What you buy is geometry, not speed. The state becomes one point in -dimensional phase space, the dynamics an incompressible flow , and structural facts fall out for free: exactly one trajectory per point, conservation laws harvested by inspection (cyclic coordinate , as in the satellite example), Liouville's theorem, Poisson brackets, and the doors to canonical transformations and Hamilton–Jacobi theory. The practical dividends are real too: symplectic integrators with bounded energy error over gigayears, and Hamiltonian Monte Carlo running inside every Stan model. And via , it is the classical formalism quantum mechanics is built on.
Why are and varied independently in the phase-space action when is defined from ?
Because in the Hamiltonian setting that definition is demoted from an input to an output. Extremize wiggling and separately, and the coefficient of forces — which for a standard says precisely . The momentum–velocity relation you were afraid of losing reappears as half of the equations of motion instead of being fed in by hand. Nothing is double-counted: you enlarged the space of curves, and stationarity itself glues back to on the solution. That is the precise sense in which coordinates and momenta are "equal citizens" — and note the asymmetry that only needs pinning at the endpoints.
How can be conserved without being the energy — or equal without being conserved?
Because those are two independent theorems with different hypotheses. Conservation comes from equation (3): , so is conserved exactly when it carries no explicit time dependence — nothing else matters. The identification comes from equation (7) and needs its own hypotheses: kinetic energy homogeneous quadratic in the velocities and static, velocity-independent constraints, so that Euler's theorem gives . A bead on a steadily rotating hoop breaks the second theorem but not the first: is conserved yet is not . A particle in an externally driven, time-varying potential breaks the first but not the second: at every instant, yet and energy is pumped in. Check each hypothesis separately.
Why the whole construction? Can't I just substitute into ?
Try it: for the oscillator you get , and no recipe applied to gives the right dynamics — the sign of the kinetic term is wrong for that. The issue is what the function's slopes mean. The differential of is : its natural response variables are , and blind substitution scrambles them. Subtracting from is engineered so the and terms annihilate — Step 2 of the derivation — leaving with only , , . That is the Legendre transform: the same trade thermodynamics makes between energy and free energy, swapping the fundamental variable without losing information.
A pendulum passes through the same position twice every period — doesn't that violate the no-crossing rule?
The no-crossing theorem lives in phase space, not in configuration space. The state is the pair , and the bob sweeping through the bottom moving right is a different phase point from the bob at the same moving left — versus . On the phase portrait these sit on opposite sides of the ellipse, no collision anywhere. What the first-order structure forbids is two distinct trajectories through one point: since assigns a unique velocity to each point, the point fixes the entire future and past. A single closed orbit revisiting its own points periodically is fine — that is just periodicity. The apparent crossings you imagine are shadows: projections of the ellipse onto the -axis.
Why doesn't a Hamiltonian system ever settle down to equilibrium like a damped one does?
Because there is no downhill. The phase velocity is the -rotated gradient, , so motion runs along the contour lines of , never descending the landscape — that is the content of for autonomous systems. Liouville's theorem then makes settling geometrically impossible: an attractor would compress a blob of initial conditions toward a point, but equation (6) says the flow's divergence vanishes identically, so phase volume is exactly conserved. Friction escapes the argument only by leaving the formalism: a drag force is not generated by any , and adding it makes trajectories spiral inward and volumes contract. The absence of attractors is the geometric fingerprint of Hamiltonian dynamics.
If a phase blob shears into a thin filament, what does Liouville's theorem actually conserve — and does it forbid chaos?
Volume only — nothing protects the shape. The free-particle panel in the figure shows the mild version: points with larger move faster, so a square blob shears into a parallelogram of identical area. Chaotic Hamiltonian systems do something far more violent: they stretch the blob exponentially along some directions while compressing it along others, the product staying exactly fixed, until the filament folds into fantastically fine tendrils threading the energy surface. So Liouville and chaos coexist happily — incompressibility constrains the bookkeeping, not the complexity. The theorem's payoffs lie elsewhere: it is why the acceptance rule in Hamiltonian Monte Carlo is exact, and why statistical mechanics can put a well-defined, time-invariant probability measure on phase space at all.
Is quantum mechanics secretly contained in the Poisson bracket, since brackets become commutators over ?
Contained, no — templated, yes. Equation (4), , becomes Heisenberg's equation of motion under Dirac's 1925 substitution, and the fundamental bracket becomes . The classical formalism even flags where will land: the oscillator's phase-space area in worked example 1 is the action variable that old quantum theory forced to be an integer multiple of . But quantization adds genuinely new content — states, operators, superposition, and the value of itself — that no amount of classical manipulation produces; the correspondence is structural, not derivational. It is still the deepest reason this page matters: Hamilton's and its bracket algebra are the exact classical skeleton on which quantum mechanics was hung.