Classical Mechanics

Canonical Transformations and Generating Functions in Hamiltonian Mechanics

Swap position and momentum in the Hamiltonian for a mass on a spring — literally set Q = p/(mω) and P = −mωq — and the tangled equations of a harmonic oscillator flatten into a straight line: the new "position" simply advances at constant angular velocity ω while the new "momentum" is a fixed constant of the motion. That single trick, executed with a generating function, is the heart of a canonical transformation: a change of the phase-space coordinates (q, p) → (Q, P) that preserves the exact form of Hamilton's equations.

A canonical transformation is a coordinate change on phase space that leaves the symplectic structure — the fundamental Poisson-bracket relations {q, p} = 1 — intact, so that dynamics still obey q̇ = ∂H/∂p, ṗ = −∂H/∂q in the new variables. A generating function is the scalar potential-like object F(old, new, t) that manufactures such a transformation and, in the process, tells you exactly how the Hamiltonian transforms.

  • TypePhase-space coordinate transformation
  • RegimeClassical Hamiltonian mechanics
  • Formalized byJacobi, 1837–1843 (building on Hamilton, 1834–35)
  • Key equationp·dq − H dt = P·dQ − K dt + dF
  • InvariantPoisson brackets & phase-space volume (Liouville)
  • Governing PDEHamilton-Jacobi: ∂S/∂t + H(q, ∂S/∂q, t) = 0

Interactive visualization

Press play, or step through manually. The visualization is yours to drive — try it before reading on.

Open visualization fullscreen ↗

Watch the 60-second explainer

A condensed visual walkthrough — narrated, captioned, under a minute.

What a canonical transformation actually is

In Hamiltonian mechanics a system of n degrees of freedom lives in a 2n-dimensional phase space with coordinates (q₁…qₙ, p₁…pₙ). The state evolves by Hamilton's equations, q̇ᵢ = ∂H/∂pᵢ and ṗᵢ = −∂H/∂qᵢ. A canonical (or contact) transformation is a change of variables (q, p) → (Q(q,p,t), P(q,p,t)) for which there exists a new Hamiltonian K(Q, P, t) such that the equations retain their form: Q̇ᵢ = ∂K/∂Pᵢ and Ṗᵢ = −∂K/∂Qᵢ.

  • Not every coordinate change qualifies. Scaling q → 2q, p → p breaks the structure; scaling q → 2q, p → p/2 preserves it.
  • The defining invariant is the set of fundamental Poisson brackets: {Qᵢ, Pⱼ} = δᵢⱼ, {Qᵢ, Qⱼ} = 0, {Pᵢ, Pⱼ} = 0.
  • Position and momentum lose their separate identities — they become interchangeable canonical conjugates, which is why you can legitimately trade one for the other.

The payoff: choose coordinates in which K is simple — ideally where new momenta are conserved — and an intractable problem integrates trivially.

The mechanism: how a generating function builds the map

Both descriptions must obey the modified Hamilton's principle, so the two integrands can differ only by a total time derivative of some function F:

p·dq − H dt = P·dQ − K dt + dF.

F is the generating function. It must depend on one old and one new coordinate to bridge the two sets — giving four flavors, F1(q,Q,t) through F4(p,P,t), related by Legendre transforms. Take the F2 case, F2(q, P, t): rewrite dF as d(F2 − Q·P). Matching coefficients of the independent differentials dq, dP, dt yields

  • p = ∂F2/∂q (defines the old momentum),
  • Q = ∂F2/∂P (defines the new coordinate),
  • K = H + ∂F2/∂t (the transformed Hamiltonian).

So one scalar function encodes the entire 2n-dimensional map and guarantees it is canonical automatically — you never have to check the Poisson brackets. The identity transformation is F2 = qᵢPᵢ; a general point transformation Q = f(q) comes from F2 = f(q)·P.

Worked example: the harmonic oscillator

Take H = p²/(2m) + ½mω²q². Try the F1 generating function F1(q, Q) = ½ m ω q² cot Q. The rules p = ∂F1/∂q and P = −∂F1/∂Q give p = mωq·cot Q and P = mωq²/(2 sin²Q). Solving for the old variables:

  • q = √(2P/(mω)) · sin Q,
  • p = √(2mωP) · cos Q.

Substitute into H (with ∂F1/∂t = 0, so K = H): the sin² and cos² terms combine to give K = ωP. The new coordinate Q is cyclic — it does not appear in K — so its conjugate P is conserved: Ṗ = −∂K/∂Q = 0. Meanwhile Q̇ = ∂K/∂P = ω, hence Q(t) = ωt + φ.

The conserved P equals E/ω, the action variable. For a 1 kg mass, ω = 2π rad/s, amplitude 0.1 m: E = ½mω²A² ≈ 0.197 J, so P = E/ω ≈ 0.0314 J·s, and Q sweeps 2π every second. A nonlinear problem became a uniform rotation.

How it is used: Hamilton-Jacobi and action-angle variables

The most consequential application is the Hamilton-Jacobi equation. Demand a transformation to variables in which K ≡ 0, so every new coordinate and momentum is constant. Using an F2-type generator called Hamilton's principal function S(q, P, t) with p = ∂S/∂q, the condition K = H + ∂S/∂t = 0 becomes the first-order nonlinear PDE

∂S/∂t + H(q₁…qₙ, ∂S/∂q₁…∂S/∂qₙ, t) = 0.

A complete integral of this single PDE solves the entire dynamics — no separate integration of 2n ODEs needed.

  • For bounded, separable, periodic motion one instead builds action-angle variables: the action Jᵢ = (1/2π)∮ pᵢ dqᵢ is a canonical momentum, its conjugate angle θᵢ advances linearly at frequency νᵢ = ∂H/∂Jᵢ.
  • This is how orbital frequencies are extracted in celestial mechanics and how the old Bohr–Sommerfeld quantization, ∮ p dq = nh, was stated (1915–16).
  • In accelerator and plasma physics, canonical perturbation theory tames near-integrable Hamiltonians.

Canonical transformations sit inside a family of related ideas that are easy to conflate:

  • vs. point transformations (Lagrangian): A Lagrangian coordinate change acts only on configuration space, Q = f(q), and momenta follow passively. Canonical transformations mix q and p freely — a strictly larger group.
  • vs. gauge/general coordinate changes: An arbitrary phase-space change need not preserve Hamilton's equations; only the symplectic subset (those satisfying the symplectic condition MᵀJM = J, where J is the standard symplectic matrix and M the Jacobian) does.
  • vs. time evolution: The flow generated by H is itself a continuous canonical transformation — Hamiltonian dynamics is a one-parameter family of them, which is why phase-space volume is conserved (Liouville's theorem).
  • vs. unitary transformations (quantum): The quantum analog. Poisson brackets {A,B} promote to commutators (1/iℏ)[Â,B̂]; generating functions correspond to unitary operators.

Infinitesimal canonical transformations reveal the deepest fact: any conserved quantity G generates a symmetry via δq = ε{q, G}, the classical seed of Noether's theorem.

Significance, history, and open threads

William Rowan Hamilton introduced the characteristic and principal functions in his optics-and-dynamics papers of 1834–1835. Carl Gustav Jacob Jacobi (1837 onward, with his Vorlesungen über Dynamik completed 1842–43 and published posthumously in 1866) generalized them into the full theory of canonical transformations and generating functions, turning the Hamilton-Jacobi equation into a constructive integration method.

  • Why it endures: it unified mechanics, optics, and later quantum theory — Schrödinger's 1926 wave equation grew directly out of the Hamilton-Jacobi analogy (S ↔ ℏ·phase).
  • Modern reach: symplectic integrators for long-term solar-system simulations (Wisdom–Holman, 1991) are built from canonical maps that conserve phase-space volume over billions of steps.

Open and hard cases: the KAM theorem (Kolmogorov 1954, Arnold & Moser 1962–63) shows which invariant tori survive perturbation, but constructing the generating function for a generically non-integrable system is impossible in closed form — small-divisor resonances make the perturbation series diverge, the mathematical fingerprint of chaos.

The four standard types of generating function. Each depends on one old variable and one new variable; the partial derivatives yield the transformation equations. K is the new Hamiltonian.
TypeIndependent variablesTransformation equationsNew Hamiltonian K
F1(q, Q, t)old q, new Qp = ∂F1/∂q, P = −∂F1/∂QK = H + ∂F1/∂t
F2(q, P, t)old q, new Pp = ∂F2/∂q, Q = ∂F2/∂PK = H + ∂F2/∂t
F3(p, Q, t)old p, new Qq = −∂F3/∂p, P = −∂F3/∂QK = H + ∂F3/∂t
F4(p, P, t)old p, new Pq = −∂F4/∂p, Q = ∂F4/∂PK = H + ∂F4/∂t
Identity (F2)F2 = q·PQ = q, P = pK = H
Point transf. (F2)F2 = f(q)·PQ = f(q)K = H + ∂F2/∂t

Frequently asked questions

What is a canonical transformation in simple terms?

It is a change of phase-space variables (q, p) → (Q, P) that keeps Hamilton's equations in the same form, so the new coordinates still evolve by Q̇ = ∂K/∂P and Ṗ = −∂K/∂Q for some new Hamiltonian K. Crucially it preserves the fundamental Poisson brackets {Q, P} = 1. The goal is to reach coordinates in which the dynamics look simpler, ideally with conserved momenta.

What is a generating function and why are there four types?

A generating function is a single scalar function F that produces a canonical transformation through its partial derivatives, automatically guaranteeing the map is canonical. There are four types (F1–F4) because F must mix one old variable with one new variable to bridge the two coordinate sets, and there are four ways to pick that pair: (q,Q), (q,P), (p,Q), (p,P). They are related to one another by Legendre transforms.

How do I know if a transformation is canonical?

Two equivalent tests. First, check the fundamental Poisson brackets: {Qᵢ,Pⱼ} = δᵢⱼ and {Qᵢ,Qⱼ} = {Pᵢ,Pⱼ} = 0. Second, the symplectic condition on the Jacobian matrix M of the transformation: MᵀJM = J, where J is the standard symplectic matrix. If either holds, a valid generating function exists and the map preserves phase-space volume.

What is the connection to the Hamilton-Jacobi equation?

The Hamilton-Jacobi method seeks a canonical transformation to variables in which the new Hamiltonian K is zero, making every new coordinate and momentum constant. Its F2-type generating function is Hamilton's principal function S, and the condition ∂S/∂t + H(q, ∂S/∂q, t) = 0 is the Hamilton-Jacobi equation. A complete solution of that one PDE solves the whole dynamical problem.

What are action-angle variables and how do they relate?

They are a special canonical coordinate set for bounded periodic motion. The action Jᵢ = (1/2π)∮ pᵢ dqᵢ becomes a conserved momentum, and its conjugate angle θᵢ increases linearly in time at frequency νᵢ = ∂H/∂Jᵢ. They make orbital and vibrational frequencies fall out directly, and historically underpinned the Bohr–Sommerfeld quantization condition ∮ p dq = nh.

Does time evolution count as a canonical transformation?

Yes. The flow generated by the Hamiltonian is itself a continuous, one-parameter family of canonical transformations, with H acting as the infinitesimal generator. Because each step preserves phase-space volume, this is exactly why Liouville's theorem holds — a phase-space region's volume is conserved as it is carried along by the dynamics, even as its shape distorts.