Intuition The big picture (WHY does this object exist?)
Lagrangian mechanics describes a system using coordinates q i q_i q i and velocities q ˙ i \dot q_i q ˙ i . But velocity is a slightly awkward variable: it lives "tangent" to motion. The Hamiltonian rephrases the SAME physics using coordinates q i q_i q i and momenta p i p_i p i instead.
The deep reason this is worth doing: in many systems H H H equals the total energy and is conserved , and the equations of motion become beautifully symmetric (first-order, not second-order). The mathematical tool that swaps "velocity" for "momentum" is the Legendre transform .
Given a Lagrangian L ( q i , q ˙ i , t ) L(q_i,\dot q_i,t) L ( q i , q ˙ i , t ) , define the conjugate (generalized) momentum
p i ≡ ∂ L ∂ q ˙ i . p_i \equiv \frac{\partial L}{\partial \dot q_i}. p i ≡ ∂ q ˙ i ∂ L .
The Hamiltonian is the Legendre transform of L L L with respect to the velocities:
H ≡ ∑ i p i q ˙ i − L \boxed{\,H \equiv \sum_i p_i\,\dot q_i \;-\; L\,} H ≡ i ∑ p i q ˙ i − L
and we then express H H H as a function H ( q i , p i , t ) H(q_i,p_i,t) H ( q i , p i , t ) — every q ˙ i \dot q_i q ˙ i must be eliminated in favour of p i p_i p i .
The single most important rule, and the one beginners forget:
Common mistake Steel-man: "
H = ∑ p i q ˙ i − L H = \sum p_i\dot q_i - L H = ∑ p i q ˙ i − L , so I'll just leave q ˙ \dot q q ˙ in the answer."
Why it feels right: the formula literally contains q ˙ i \dot q_i q ˙ i , so writing it seems honest.
Why it's wrong: H H H is supposed to be a function of ( q , p , t ) (q,p,t) ( q , p , t ) . The whole point of the Legendre transform is to trade variables. A function of ( q , p ) (q,p) ( q , p ) that still secretly contains q ˙ \dot q q ˙ is ill-defined.
Fix: invert p i = ∂ L / ∂ q ˙ i p_i = \partial L/\partial \dot q_i p i = ∂ L / ∂ q ˙ i to get q ˙ i ( q , p ) \dot q_i(q,p) q ˙ i ( q , p ) , then substitute so no q ˙ \dot q q ˙ remains.
Intuition WHAT is a Legendre transform, really?
Take a convex function f ( x ) f(x) f ( x ) . Instead of describing the curve by points ( x , f ) (x, f) ( x , f ) , describe it by its slopes : let p = f ′ ( x ) p = f'(x) p = f ′ ( x ) , and define g ( p ) = p x − f g(p) = px - f g ( p ) = p x − f . The new function g ( p ) g(p) g ( p ) encodes the same curve, but now the independent variable is the slope. Energy-momentum is exactly this: momentum p = ∂ L / ∂ q ˙ p=\partial L/\partial\dot q p = ∂ L / ∂ q ˙ is the "slope" of L L L in the velocity direction.
HOW to derive H H H and confirm it's a clean function of ( q , p , t ) (q,p,t) ( q , p , t ) . Start from a tiny change in L L L :
d L = ∑ i ∂ L ∂ q i d q i + ∑ i ∂ L ∂ q ˙ i d q ˙ i + ∂ L ∂ t d t . dL = \sum_i \frac{\partial L}{\partial q_i}\,dq_i
+ \sum_i \frac{\partial L}{\partial \dot q_i}\,d\dot q_i
+ \frac{\partial L}{\partial t}\,dt. d L = i ∑ ∂ q i ∂ L d q i + i ∑ ∂ q ˙ i ∂ L d q ˙ i + ∂ t ∂ L d t .
Why this step? This is just the total differential — it lists how L L L responds to changing each of its arguments.
Now use the definition p i = ∂ L / ∂ q ˙ i p_i = \partial L/\partial\dot q_i p i = ∂ L / ∂ q ˙ i and the Euler–Lagrange equation
d d t ∂ L ∂ q ˙ i = ∂ L ∂ q i \dfrac{d}{dt}\dfrac{\partial L}{\partial \dot q_i} = \dfrac{\partial L}{\partial q_i} d t d ∂ q ˙ i ∂ L = ∂ q i ∂ L , i.e. p ˙ i = ∂ L / ∂ q i \dot p_i = \partial L/\partial q_i p ˙ i = ∂ L / ∂ q i :
d L = ∑ i p ˙ i d q i + ∑ i p i d q ˙ i + ∂ L ∂ t d t . dL = \sum_i \dot p_i\,dq_i + \sum_i p_i\,d\dot q_i + \frac{\partial L}{\partial t}\,dt. d L = i ∑ p ˙ i d q i + i ∑ p i d q ˙ i + ∂ t ∂ L d t .
Why this step? We rewrote the awkward partials in terms of p i p_i p i and p ˙ i \dot p_i p ˙ i , which are the variables we actually want.
The term ∑ p i d q ˙ i \sum p_i\,d\dot q_i ∑ p i d q ˙ i still contains the velocity differential we want to eliminate. Use the product rule to flip it:
∑ i p i d q ˙ i = d ( ∑ i p i q ˙ i ) − ∑ i q ˙ i d p i . \sum_i p_i\,d\dot q_i = d\!\Big(\sum_i p_i\dot q_i\Big) - \sum_i \dot q_i\,dp_i. i ∑ p i d q ˙ i = d ( i ∑ p i q ˙ i ) − i ∑ q ˙ i d p i .
Why this step? This is the crux of the Legendre trick: d ( p q ˙ ) = p d q ˙ + q ˙ d p d(p\dot q)=p\,d\dot q+\dot q\,dp d ( p q ˙ ) = p d q ˙ + q ˙ d p , so we swap a d q ˙ d\dot q d q ˙ term for a d p dp d p term.
Substitute and rearrange:
d ( ∑ i p i q ˙ i − L ⏟ = H ) = ∑ i q ˙ i d p i − ∑ i p ˙ i d q i − ∂ L ∂ t d t . d\!\Big(\underbrace{\sum_i p_i\dot q_i - L}_{\;=\;H\;}\Big)
= \sum_i \dot q_i\,dp_i - \sum_i \dot p_i\,dq_i - \frac{\partial L}{\partial t}\,dt. d ( = H i ∑ p i q ˙ i − L ) = i ∑ q ˙ i d p i − i ∑ p ˙ i d q i − ∂ t ∂ L d t .
Why this step? Moving d L dL d L to the left and grouping shows that the natural quantity whose differential involves only d p dp d p , d q dq d q , d t dt d t is precisely H = ∑ p i q ˙ i − L H=\sum p_i\dot q_i - L H = ∑ p i q ˙ i − L . Its differential contains no d q ˙ d\dot q d q ˙ — proof that H H H is genuinely a function of ( q , p , t ) (q,p,t) ( q , p , t ) .
H H H often (but not always!) equals E E E
Write L = T − V L = T - V L = T − V . For "natural" systems the kinetic energy T T T is a homogeneous quadratic in the velocities: T = 1 2 ∑ j k a j k ( q ) q ˙ j q ˙ k T = \tfrac12\sum_{jk}a_{jk}(q)\dot q_j\dot q_k T = 2 1 ∑ j k a j k ( q ) q ˙ j q ˙ k . Euler's theorem on homogeneous functions then says ∑ i q ˙ i ∂ T / ∂ q ˙ i = 2 T \sum_i \dot q_i\,\partial T/\partial \dot q_i = 2T ∑ i q ˙ i ∂ T / ∂ q ˙ i = 2 T .
If V V V does not depend on velocities, p i = ∂ L / ∂ q ˙ i = ∂ T / ∂ q ˙ i p_i=\partial L/\partial\dot q_i = \partial T/\partial\dot q_i p i = ∂ L / ∂ q ˙ i = ∂ T / ∂ q ˙ i , so
∑ i p i q ˙ i = ∑ i q ˙ i ∂ T ∂ q ˙ i = 2 T , \sum_i p_i\dot q_i = \sum_i \dot q_i\frac{\partial T}{\partial\dot q_i} = 2T, i ∑ p i q ˙ i = i ∑ q ˙ i ∂ q ˙ i ∂ T = 2 T ,
hence
H = 2 T − L = 2 T − ( T − V ) = T + V = E . H = 2T - L = 2T - (T - V) = T + V = E. H = 2 T − L = 2 T − ( T − V ) = T + V = E .
Common mistake Steel-man: "
H H H is always the energy."
Why it feels right: in nearly every intro problem (free particle, oscillator, pendulum), H = E H=E H = E .
Why it's wrong: the equality needed (i) T T T quadratic in q ˙ \dot q q ˙ with no linear/explicit-time terms and (ii) V V V velocity-independent. With moving constraints (e.g. a bead on a rotating wire) or velocity-dependent potentials (magnetic forces), H ≠ T + V H \ne T+V H = T + V in general.
Separately: H H H is conserved iff ∂ H / ∂ t = 0 \partial H/\partial t = 0 ∂ H / ∂ t = 0 , which by the derivation means ∂ L / ∂ t = 0 \partial L/\partial t=0 ∂ L / ∂ t = 0 . Conservation and "H = E H=E H = E " are different conditions — don't merge them.
Worked example (a) 1D particle in a potential
L = 1 2 m x ˙ 2 − V ( x ) L = \tfrac12 m\dot x^2 - V(x) L = 2 1 m x ˙ 2 − V ( x ) .
Momentum: p = ∂ L / ∂ x ˙ = m x ˙ p=\partial L/\partial\dot x = m\dot x p = ∂ L / ∂ x ˙ = m x ˙ . (Why: differentiate L L L in x ˙ \dot x x ˙ .)
Invert: x ˙ = p / m \dot x = p/m x ˙ = p / m . (Why: must remove x ˙ \dot x x ˙ .)
Assemble: H = p x ˙ − L = p ⋅ p m − ( 1 2 m ( p / m ) 2 − V ) = p 2 m − p 2 2 m + V H = p\dot x - L = p\cdot\frac{p}{m} - \big(\tfrac12 m(p/m)^2 - V\big) = \frac{p^2}{m} - \frac{p^2}{2m} + V H = p x ˙ − L = p ⋅ m p − ( 2 1 m ( p / m ) 2 − V ) = m p 2 − 2 m p 2 + V .
H = p 2 2 m + V ( x ) = T + V . ✓ \boxed{H = \frac{p^2}{2m} + V(x)} = T+V.\;✓ H = 2 m p 2 + V ( x ) = T + V . ✓
Worked example (b) Plane pendulum (length
ℓ \ell ℓ , mass m m m , angle θ \theta θ )
L = 1 2 m ℓ 2 θ ˙ 2 + m g ℓ cos θ L = \tfrac12 m\ell^2\dot\theta^2 + mg\ell\cos\theta L = 2 1 m ℓ 2 θ ˙ 2 + m g ℓ cos θ .
Momentum: p θ = m ℓ 2 θ ˙ p_\theta = m\ell^2\dot\theta p θ = m ℓ 2 θ ˙ . (angular momentum — note the units, kg⋅m 2 / s \text{kg·m}^2/\text{s} kg⋅m 2 / s .)
Invert: θ ˙ = p θ / ( m ℓ 2 ) \dot\theta = p_\theta/(m\ell^2) θ ˙ = p θ / ( m ℓ 2 ) .
Assemble: H = p θ θ ˙ − L = p θ 2 2 m ℓ 2 − m g ℓ cos θ = E H = p_\theta\dot\theta - L = \dfrac{p_\theta^2}{2m\ell^2} - mg\ell\cos\theta = E H = p θ θ ˙ − L = 2 m ℓ 2 p θ 2 − m g ℓ cos θ = E .
Check Hamilton's eqns: θ ˙ = ∂ H / ∂ p θ = p θ / ( m ℓ 2 ) \dot\theta=\partial H/\partial p_\theta = p_\theta/(m\ell^2) θ ˙ = ∂ H / ∂ p θ = p θ / ( m ℓ 2 ) ✓ (consistent with definition), and p ˙ θ = − ∂ H / ∂ θ = − m g ℓ sin θ \dot p_\theta = -\partial H/\partial\theta = -mg\ell\sin\theta p ˙ θ = − ∂ H / ∂ θ = − m g ℓ sin θ , i.e. m ℓ 2 θ ¨ = − m g ℓ sin θ m\ell^2\ddot\theta=-mg\ell\sin\theta m ℓ 2 θ ¨ = − m g ℓ sin θ — the familiar pendulum equation. ✓
Worked example (c) Bead on a wire rotating at fixed
ω \omega ω (where H ≠ E H\ne E H = E !)
Constraint ϕ = ω t \phi=\omega t ϕ = ω t , radial coord r r r . T = 1 2 m ( r ˙ 2 + r 2 ω 2 ) T=\tfrac12 m(\dot r^2 + r^2\omega^2) T = 2 1 m ( r ˙ 2 + r 2 ω 2 ) , V = 0 V=0 V = 0 , so
L = 1 2 m r ˙ 2 + 1 2 m r 2 ω 2 L = \tfrac12 m\dot r^2 + \tfrac12 m r^2\omega^2 L = 2 1 m r ˙ 2 + 2 1 m r 2 ω 2 .
Momentum: p r = m r ˙ p_r=m\dot r p r = m r ˙ , so r ˙ = p r / m \dot r = p_r/m r ˙ = p r / m .
Assemble: H = p r r ˙ − L = p r 2 2 m − 1 2 m r 2 ω 2 H = p_r\dot r - L = \dfrac{p_r^2}{2m} - \tfrac12 m r^2\omega^2 H = p r r ˙ − L = 2 m p r 2 − 2 1 m r 2 ω 2 .
But the energy is E = T + V = 1 2 m r ˙ 2 + 1 2 m r 2 ω 2 = p r 2 2 m + 1 2 m r 2 ω 2 E=T+V=\tfrac12 m\dot r^2 + \tfrac12 m r^2\omega^2 = \dfrac{p_r^2}{2m}+\tfrac12 m r^2\omega^2 E = T + V = 2 1 m r ˙ 2 + 2 1 m r 2 ω 2 = 2 m p r 2 + 2 1 m r 2 ω 2 .
So H = E − m r 2 ω 2 ≠ E H = E - m r^2\omega^2 \ne E H = E − m r 2 ω 2 = E . (Why: the constraint is time-dependent, T T T has a r ˙ \dot r r ˙ -independent piece, so Euler's theorem giving 2 T 2T 2 T fails.) However ∂ L / ∂ t = 0 \partial L/\partial t=0 ∂ L / ∂ t = 0 , so H H H is still conserved even though it isn't the energy. A perfect steel-man case.
What is the conjugate momentum p i p_i p i in terms of L L L ? p i = ∂ L / ∂ q ˙ i p_i=\partial L/\partial\dot q_i p i = ∂ L / ∂ q ˙ i State the definition of the Hamiltonian. H = ∑ i p i q ˙ i − L H=\sum_i p_i\dot q_i - L H = ∑ i p i q ˙ i − L , then expressed as
H ( q , p , t ) H(q,p,t) H ( q , p , t ) .
After writing H = ∑ p i q ˙ i − L H=\sum p_i\dot q_i - L H = ∑ p i q ˙ i − L , what MUST you do next? Eliminate all
q ˙ i \dot q_i q ˙ i by inverting
p i = ∂ L / ∂ q ˙ i p_i=\partial L/\partial\dot q_i p i = ∂ L / ∂ q ˙ i , so
H H H depends only on
( q , p , t ) (q,p,t) ( q , p , t ) .
What mathematical operation turns L L L into H H H ? A Legendre transform with respect to the velocities
q ˙ i \dot q_i q ˙ i .
State Hamilton's canonical equations. q ˙ i = ∂ H / ∂ p i \dot q_i=\partial H/\partial p_i q ˙ i = ∂ H / ∂ p i and
p ˙ i = − ∂ H / ∂ q i \dot p_i=-\partial H/\partial q_i p ˙ i = − ∂ H / ∂ q i .
How many and what order are Hamilton's equations vs Euler–Lagrange? 2 n 2n 2 n first-order ODEs vs
n n n second-order ODEs.
Condition for H H H to equal total energy T + V T+V T + V ? T T T homogeneous quadratic in
q ˙ \dot q q ˙ (no explicit-time/linear velocity terms) AND
V V V velocity-independent.
Condition for H H H to be conserved? ∂ H / ∂ t = 0 \partial H/\partial t=0 ∂ H / ∂ t = 0 , equivalently
∂ L / ∂ t = 0 \partial L/\partial t=0 ∂ L / ∂ t = 0 (no explicit time dependence).
Why does ∑ p i q ˙ i = 2 T \sum p_i\dot q_i=2T ∑ p i q ˙ i = 2 T for natural systems? Euler's theorem on the homogeneous quadratic
T T T in the
q ˙ i \dot q_i q ˙ i .
Give a system where H H H is conserved but H ≠ E H\ne E H = E . Bead on a uniformly rotating wire (time-dependent constraint).
What is ∂ H / ∂ t \partial H/\partial t ∂ H / ∂ t in terms of L L L ? ∂ H / ∂ t = − ∂ L / ∂ t \partial H/\partial t=-\partial L/\partial t ∂ H / ∂ t = − ∂ L / ∂ t .
Recall Feynman: explain it to a 12-year-old
Imagine describing a moving toy car. You could track "where it is and how fast it's going" (that's the Lagrangian way: position + speed). Or you could track "where it is and how much push it carries" (that's momentum — the Hamiltonian way). They describe the exact same car! The Hamiltonian is a clever recipe, H = p q ˙ − L H=p\dot q - L H = p q ˙ − L , that switches you from the "speed" description to the "push" description. The bonus: in the push-description, the total energy is usually just sitting right there in front of you, and the motion rules become super simple — one neat rule for how position changes, one for how push changes.
Mnemonic Remembering it all
"P-Q minus L, then Q must leave."
H = p q -dot − L H = pq\text{-dot} - L H = pq -dot − L , and the velocity q ˙ \dot q q ˙ must leave the room (be eliminated). For the sign of Hamilton's equations: "position follows p p p with a plus, momentum follows q q q with a minus" — the minus sits on the p ˙ \dot p p ˙ equation.
Legendre Transform — the engine that builds H H H from L L L ; reappears in thermodynamics (U → F , G , H U\to F,G,H U → F , G , H ).
Lagrangian Mechanics — where L L L , p i p_i p i , and Euler–Lagrange come from.
Hamilton's Canonical Equations — the first-order equations born from d H dH d H .
Conservation Laws & Noether's Theorem — ∂ L / ∂ t = 0 ⇒ H \partial L/\partial t=0\Rightarrow H ∂ L / ∂ t = 0 ⇒ H conserved.
Poisson Brackets — next step: f ˙ = { f , H } \dot f=\{f,H\} f ˙ = { f , H } generalizes Hamilton's equations.
Phase Space — the ( q , p ) (q,p) ( q , p ) arena H H H naturally lives in.
gives H = sum p qdot minus L
invert to get qdot of q p
Mistake: leaving qdot in H
Intuition Hinglish mein samjho
Dekho, Lagrangian mechanics mein hum system ko coordinate q q q aur velocity q ˙ \dot q q ˙ se describe karte hain. Hamiltonian ka idea simple hai: velocity ki jagah hum momentum p p p use karna chahte hain, kyunki momentum zyada natural variable hai aur usually total energy seedha dikh jaati hai. Yeh swap karne ka tool hai Legendre transform , aur formula banta hai H = ∑ p i q ˙ i − L H=\sum p_i\dot q_i - L H = ∑ p i q ˙ i − L .
Sabse important baat — jo students bhool jaate hain — yeh hai ki H H H likhne ke baad usme se saare q ˙ \dot q q ˙ hatana zaroori hai. Pehle p i = ∂ L / ∂ q ˙ i p_i=\partial L/\partial\dot q_i p i = ∂ L / ∂ q ˙ i se q ˙ \dot q q ˙ ko p p p ke terms mein invert karo, phir substitute karo. Tabhi H H H sahi maayne mein sirf ( q , p , t ) (q,p,t) ( q , p , t ) ka function banta hai. Agar q ˙ \dot q q ˙ andar reh gaya toh answer galat hai.
H H H kab energy ke barabar hota hai? Jab kinetic energy T T T velocity mein purely quadratic ho aur potential V V V velocity pe depend na kare. Tab Euler's theorem se ∑ p q ˙ = 2 T \sum p\dot q = 2T ∑ p q ˙ = 2 T , aur H = 2 T − L = T + V = E H = 2T - L = T+V = E H = 2 T − L = T + V = E . Lekin yaad rakho: rotating wire jaise time-dependent constraint waale problems mein H ≠ E H\ne E H = E ho sakta hai, phir bhi H H H conserved reh sakta hai agar ∂ L / ∂ t = 0 \partial L/\partial t=0 ∂ L / ∂ t = 0 . Conservation aur "H = E H=E H = E " do alag conditions hain — inhe mat mila do.
Bonus: derivation se hi Hamilton ke do canonical equations free mein mil jaate hain — q ˙ = ∂ H / ∂ p \dot q=\partial H/\partial p q ˙ = ∂ H / ∂ p aur p ˙ = − ∂ H / ∂ q \dot p=-\partial H/\partial q p ˙ = − ∂ H / ∂ q . Yeh first-order equations second-order Euler–Lagrange ki jagah le lete hain, aur phase space ( q , p ) (q,p) ( q , p ) mein motion ki picture bahut clean ho jaati hai.