2.1.16Analytical Mechanics
Canonical transformations — generating functions
1,780 words8 min readdifficulty · medium5 backlinks
WHAT is a canonical transformation?
WHY a generating function exists. Both the old and new equations come from a variational principle (Hamilton's modified principle):
\delta\!\int\!\Big(\sum_i P_i\dot Q_i - K\Big)dt=0.$$ Two integrands give the same equations of motion iff they differ by a **total time derivative** of some function $F$ (whose variation at fixed endpoints vanishes): $$\boxed{\;\sum_i p_i\dot q_i - H \;=\; \sum_i P_i\dot Q_i - K \;+\;\frac{dF}{dt}\;}$$ That function $==F==$ is the **generating function**. Everything follows from this one equation. --- ## HOW the four types arise $F$ can depend on a mix of old and new variables. We need it to depend on **one old + one new** variable per degree of freedom (so the transformation is fully determined). This gives **4 types**. ### Type 1: $F=F_1(q,Q,t)$ Multiply the boxed relation by $dt$: $$p_i\,dq_i - H\,dt = P_i\,dQ_i - K\,dt + dF_1.$$ Since $dF_1=\frac{\partial F_1}{\partial q_i}dq_i+\frac{\partial F_1}{\partial Q_i}dQ_i+\frac{\partial F_1}{\partial t}dt$, match coefficients of the **independent differentials** $dq_i$, $dQ_i$, $dt$: > [!formula] Type-1 relations > $$p_i=\frac{\partial F_1}{\partial q_i},\qquad > P_i=-\frac{\partial F_1}{\partial Q_i},\qquad > K=H+\frac{\partial F_1}{\partial t}.$$ > **Why this works:** $q_i,Q_i,t$ are treated as independent, so their coefficients must match > *separately* on both sides. ### Type 2: $F=F_2(q,P,t)-\sum_i Q_iP_i$ (Legendre transform in $Q$) We want a generator in $(q,P)$. Use $P_i dQ_i = d(P_iQ_i)-Q_i dP_i$ and absorb $d(\sum Q_iP_i)$: > [!formula] Type-2 relations > $$p_i=\frac{\partial F_2}{\partial q_i},\qquad > Q_i=\frac{\partial F_2}{\partial P_i},\qquad > K=H+\frac{\partial F_2}{\partial t}.$$ The other two follow the same Legendre-swap pattern: | Type | Variables | Relations | |------|-----------|-----------| | $F_1(q,Q)$ | old $q$, new $Q$ | $p=\partial_q F_1,\;\;P=-\partial_Q F_1$ | | $F_2(q,P)$ | old $q$, new $P$ | $p=\partial_q F_2,\;\;Q=\partial_P F_2$ | | $F_3(p,Q)$ | old $p$, new $Q$ | $q=-\partial_p F_3,\;\;P=-\partial_Q F_3$ | | $F_4(p,P)$ | old $p$, new $P$ | $q=-\partial_p F_4,\;\;Q=\partial_P F_4$ | In all four: $K=H+\partial F/\partial t$ (if $F$ is time-independent, $K=H$). ![[2.1.16-Canonical-transformations-—-generating-functions.png]] --- ## WORKED EXAMPLES > [!example] Example 1 — The identity hides in $F_2=qP$ > Take $F_2=\sum_i q_iP_i$. > - $p_i=\partial F_2/\partial q_i = P_i$ → **Why?** derivative w.r.t. $q_i$ pulls down $P_i$. > - $Q_i=\partial F_2/\partial P_i = q_i$ → so $Q=q,\;P=p$: the **identity** transformation. > > **Lesson:** $F_2=qP$ is the "do-nothing" generator; small additions to it give *infinitesimal* > canonical transformations (the seed of Hamiltonian flow). > [!example] Example 2 — Swapping coordinates and momenta ($F_1=qQ$) > Take $F_1=\sum_i q_iQ_i$. > - $p_i=\partial F_1/\partial q_i=Q_i$ → so $Q_i=p_i$. **Why?** match $dq$ coefficient. > - $P_i=-\partial F_1/\partial Q_i=-q_i$ → so $P_i=-q_i$. > > Result: $Q=p,\;P=-q$. Coordinates and momenta swap (up to sign)! This shows $q$ and $p$ are on > **equal footing** in phase space — there's nothing intrinsically "position" about position. > [!example] Example 3 — Harmonic oscillator, the killer app ($F_1=\tfrac12 m\omega q^2\cot Q$) > $H=\dfrac{p^2}{2m}+\dfrac12 m\omega^2 q^2$. Try $F_1(q,Q)=\dfrac{m\omega q^2}{2}\cot Q$. > 1. $p=\dfrac{\partial F_1}{\partial q}=m\omega q\cot Q$. **Why?** Type-1 rule for $p$. > 2. $P=-\dfrac{\partial F_1}{\partial Q}=\dfrac{m\omega q^2}{2\sin^2 Q}$. **Why?** $\frac{d}{dQ}\cot Q=-\csc^2Q$. > 3. Solve (2) for $q$: $q=\sqrt{\dfrac{2P}{m\omega}}\,\sin Q$. Sub into (1): $p=\sqrt{2Pm\omega}\,\cos Q$. > 4. Plug into $H$ (time-independent so $K=H$): > $$K=\frac{2Pm\omega\cos^2Q}{2m}+\frac12 m\omega^2\frac{2P}{m\omega}\sin^2Q=\omega P(\cos^2Q+\sin^2Q)=\omega P.$$ > So $K=\omega P$ — **$Q$ is cyclic!** Then $\dot P=-\partial K/\partial Q=0$ ($P$ const = energy/$\omega$), > and $\dot Q=\partial K/\partial P=\omega$ ⟹ $Q=\omega t+\phi$. We solved the oscillator with no > differential equation — just a clever generator. (This is the gateway to action–angle variables.) --- ## Common mistakes (steel-manned) > [!mistake] "Any smooth change of variables is canonical." > **Why it feels right:** in Lagrangian mechanics *any* invertible point transformation $q\to Q(q)$ > works. **Fix:** in *phase* space you mix $q$ and $p$, and you must preserve the symplectic form — > equivalently the Poisson brackets $\{Q_i,P_j\}=\delta_{ij}$, $\{Q,Q\}=\{P,P\}=0$. Most random > maps fail this. The generating-function machinery *guarantees* it automatically. > [!mistake] Forgetting the time term: "$K=H$ always." > **Why it feels right:** in the static examples it *is*. **Fix:** $K=H+\partial F/\partial t$. > The extra term is essential when $F$ depends on $t$ — that's exactly how Hamilton–Jacobi makes > $K=0$. > [!mistake] Mixing up the signs ($P=+\partial_Q F_1$). > **Why it feels right:** $p$ and $P$ "look symmetric." **Fix:** the minus comes from $dQ$ sitting > on the **right** side of the boxed equation: $P_i dQ_i$ moves over with a sign. Memorize: > *new variable on the "$F$-only" side gets the minus in Types 1 & 3*. --- ## Active recall > [!recall]- Test yourself (hide answers) > - What single equation generates ALL canonical transformations? > - Why must the two integrands differ by a total time derivative, not just a constant? > - For $F_2$, which variable is $\partial_P F_2$? > - What does $\partial F/\partial t \ne 0$ do to $H$? #flashcards/physics What defines a canonical transformation? ::: A change $(q,p)\to(Q,P)$ preserving the canonical form of Hamilton's equations for some new Hamiltonian $K$. What is the master relation generating CTs? ::: $\sum p_i\dot q_i - H = \sum P_i\dot Q_i - K + \frac{dF}{dt}$. Type-1 generating function relations? ::: $p_i=\partial F_1/\partial q_i,\;P_i=-\partial F_1/\partial Q_i,\;K=H+\partial F_1/\partial t$. Type-2 generating function relations? ::: $p_i=\partial F_2/\partial q_i,\;Q_i=\partial F_2/\partial P_i,\;K=H+\partial F_2/\partial t$. Which generator gives the identity transformation? ::: $F_2=\sum_i q_iP_i$ ⟹ $Q=q,\,P=p$. Generator $F_1=qQ$ produces? ::: $Q=p,\;P=-q$ (swap of coords and momenta). How does $K$ relate to $H$ in general? ::: $K=H+\partial F/\partial t$; equal only if $F$ is time-independent. For the harmonic oscillator, what does $F_1=\tfrac12 m\omega q^2\cot Q$ achieve? ::: It gives $K=\omega P$, making $Q$ cyclic so $P$ is constant and $Q=\omega t+\phi$. Poisson-bracket test for canonicity? ::: $\{Q_i,P_j\}=\delta_{ij},\;\{Q_i,Q_j\}=\{P_i,P_j\}=0$. > [!recall]- Feynman: explain to a 12-year-old > Imagine a treasure map where finding the treasure is super hard. A canonical transformation is > like drawing a **new grid** on the same map so the treasure lands neatly on a gridline — the > treasure didn't move, you just relabeled where things are so the path becomes a straight, boring > line. The "generating function" is the **single recipe** you write down that tells you exactly how > to redraw the grid without breaking the rules of the game (the rules being Hamilton's equations). > [!mnemonic] Remembering signs & variables > **"1Q 2P, 3Q 4P"** — *which new variable appears*: $F_1,F_3$ use new **Q**; $F_2,F_4$ use new **P**. > And **"old gets plain, lonely-new gets minus"**: the variable that appears *only* in $F$ (not the > conjugate pair argument) carries the minus sign in Types 1 & 3. ## Connections - [[Hamilton's equations]] — the form that CTs preserve. - [[Poisson brackets]] — invariant under CTs; the algebraic test of canonicity. - [[Hamilton–Jacobi equation]] — choose $F$ so that $K=0$. - [[Action–angle variables]] — Example 3 generalized. - [[Symplectic geometry]] — CT = symplectomorphism preserving $dp\wedge dq$. - [[Legendre transformation]] — relates the four generator types. - [[Liouville's theorem]] — phase-space volume is a CT invariant. ## 🖼️ Concept Map ```mermaid flowchart TD HE[Hamilton equations canonical form] CT[Canonical transformation] VP[Hamilton modified principle] F[Generating function F] K[New Hamiltonian K] F1[Type 1 F1 q,Q] F2[Type 2 F2 q,P] F3[Type 3 F3 p,Q] F4[Type 4 F4 p,P] REL[Transformation relations] CT -->|preserves| HE CT -->|requires| K VP -->|two integrands differ by dF/dt| F F -->|manufactures| CT F -->|depends on one old + one new var| F1 F -->|Legendre swap| F2 F -->|Legendre swap| F3 F -->|Legendre swap| F4 F1 -->|match differentials| REL F2 -->|match differentials| REL REL -->|gives p,P,Q and| K ``` ## 🔊 Hinglish (regional understanding) > [!intuition]- Hinglish mein samjho > Dekho, **canonical transformation** ka matlab hai phase space mein variables $(q,p)$ ko naye > variables $(Q,P)$ mein badalna, lekin is tarah ki Hamilton ke equations ka **form same rahe**. > Lagrangian mechanics mein toh bas position $q$ change karte the, par yahan hum $q$ aur $p$ dono ko > mix kar sakte hain — phase space mein dono "barabar" hote hain. Magic yeh hai ki har sahi > transformation ek single scalar function se nikalti hai — usko **generating function** $F$ kehte hain. > > Saara khel ek hi equation se chalta hai: $\sum p\,\dot q - H = \sum P\,\dot Q - K + \frac{dF}{dt}$. > Iska reason simple hai — dono purane aur naye Hamilton equations ek hi variational principle se aate > hain, aur do integrands tabhi same equations dete hain jab woh ek **total time derivative** se differ > karein. Us $F$ ko aap chaar tareeke se variables pe depend kara sakte ho ($F_1$ se $F_4$), aur har > type ke liye derivative rules nikal aate hain, jaise $p=\partial F_1/\partial q$, $P=-\partial > F_1/\partial Q$. > > Sabse zabardast example hai **harmonic oscillator**. Generator $F_1=\frac12 m\omega q^2\cot Q$ lo, > thoda algebra karo, aur naya Hamiltonian ban jaata hai $K=\omega P$ — yaani $Q$ cyclic ho gaya! Ab > $P$ constant (energy), aur $Q=\omega t+\phi$. Bina koi differential equation solve kiye humne > oscillator solve kar diya, sirf ek clever variable change se. Yahi soch aage **Hamilton–Jacobi** aur > **action-angle variables** tak le jaati hai. Sign aur variable yaad rakhne ke liye mnemonic use > karo, aur Poisson bracket test $\{Q,P\}=1$ se hamesha check kar lo ki transformation canonical hai > ya nahi. ![[audio/2.1.16-Canonical-transformations-—-generating-functions.mp3]]Go deeper — visual, from zero
Test yourself — Analytical Mechanics
Connections
Hamilton's equations of motionPhysics · 2.1.12Poisson brackets — definition, properties, connection to commutatorsPhysics · 2.1.15Hamilton-Jacobi equationPhysics · 2.1.17Action-angle variables — integrable systemsPhysics · 2.1.18Liouville's theorem — phase space volume conservationPhysics · 2.1.14Hamilton's equations of motionPhysics · 2.1.12Liouville's theorem — phase space volume conservationPhysics · 2.1.14Poisson brackets — definition, properties, connection to commutatorsPhysics · 2.1.15Hamilton-Jacobi equationPhysics · 2.1.17Action-angle variables — integrable systemsPhysics · 2.1.18