On this page
Pick better variables and a hard mechanics problem can become one you solve in a line. Canonical transformations are the rule for doing that without breaking Hamilton's equations. Here is the definition, a quick test and a full worked example.
What is a canonical transformation?
Hamiltonian mechanics, a reformulation of Lagrangian mechanics, emerged in 1833 through the work of William Rowan Hamilton. Its equations are q̇ = ∂H/∂p and ṗ = −∂H/∂q, where H is the Hamiltonian, usually the energy. You get H from the Lagrangian by a Legendre transform from L to H, the same tool that links the two pictures of mechanics.
A canonical transformation is a change of coordinates (q, p) → (Q, P) that preserves the form of Hamilton's equations. In the new variables, Q̇ = ∂K/∂P and Ṗ = −∂K/∂Q, where K is H rewritten in the new variables when the transformation does not depend on time.
David Tong's Classical Dynamics notes (University of Cambridge) add that the Poisson bracket is invariant under canonical transformations, which gives you a practical test.
How do you check that a transformation is canonical?
For one degree of freedom, a transformation is canonical when the Poisson bracket {Q, P} = 1, as in equation 4.363 of Tong's notes. Here {Q, P} = (∂Q/∂q)(∂P/∂p) − (∂Q/∂p)(∂P/∂q).
Write Q and P as functions of q and p.
Take the four partial derivatives and form the bracket.
If it simplifies to 1 everywhere, the transformation is canonical.
Try three quick cases:
Q = 2q, P = p gives {Q, P} = 2. Not canonical: you stretched position without squeezing momentum.
Q = 2q, P = p/2 gives 1. Canonical.
Q = p, P = −q gives (0)(0) − (1)(−1) = 1. Canonical, so position and momentum can swap roles.
Worked example: how does the harmonic oscillator become a free rotation?
Take a mass m on a spring with angular frequency ω. Its Hamiltonian is H = p²/2m + ½mω²q², the starting point of section 4.5.1 in Tong's notes.
Choose the new variables: Q = arctan(mωq/p) and P = H/ω = p²/(2mω) + mωq²/2.
Take the derivatives. With D = p² + m²ω²q², you get ∂Q/∂q = mωp/D, ∂Q/∂p = −mωq/D, ∂P/∂p = p/(mω) and ∂P/∂q = mωq.
Form the bracket: {Q, P} = p²/D + m²ω²q²/D = D/D = 1. The transformation is canonical.
Invert it: q = √(2P/mω) sin Q and p = √(2mωP) cos Q. Put these back into H and the sin² and cos² add to 1, leaving H = ωP.
Apply Hamilton's equations: Q̇ = ∂H/∂P = ω and Ṗ = −∂H/∂Q = 0.
So P is constant and Q grows steadily: Q = ωt + Q₀. Every ellipse in the (q, p) plane has become a straight line in the (Q, P) plane, travelled at constant speed. Tong reaches the same form, H = ωI, with I the action and θ the angle.
Notice that P = E/ω. That ratio is the quantity that stays fixed when a pendulum's string is shortened slowly, which is why the action variable matters beyond this one example.
What are generating functions and why use them?
A generating function builds a canonical transformation for you instead of guessing. Tong calls it "a simple method to construct canonical transformations" in the Cambridge notes. A function of the first kind, F(q, Q), gives p = ∂F/∂q and P = −∂F/∂Q. The Wikipedia article on canonical transformations lists all four kinds, mixing old and new variables as (q, Q), (q, P), (p, Q) and (p, P).
For the oscillator, try F = ½mωq² cot Q. Then p = ∂F/∂q = mωq cot Q, which is the same as tan Q = mωq/p. And P = −∂F/∂Q = mωq²/(2 sin²Q). Substitute q from step 4 and this is exactly P. One function, both equations, no guessing.
The point of all this is to make coordinates disappear from H. Once H depends only on P, P is conserved and Q grows linearly. Action-angle variables are also important in obtaining the frequencies of oscillatory or rotational motion without solving the equations of motion.
How should you practise canonical transformations?
Run the bracket test on five transformations of your own, including one that fails.
Redo the oscillator with m = ω = 1, where the ellipses become circles and Q is the angle measured clockwise from the p-axis.
Revise the Euler–Lagrange equation, the Lagrangian side of the same mechanics.
If Poisson brackets or phase space feel shaky, the Fermi Concept Library covers every concept in physics and mathematics, each with its own lesson. When a transformation refuses to give 1, Fermi's AI tutor works out what you already know and teaches through it on a board, checking understanding as it goes.



