2.1.11Analytical Mechanics

Hamiltonian — definition H = Σpᵢq̇ᵢ − L

2,073 words9 min readdifficulty · medium1 backlinks

1. What is the Hamiltonian?

The single most important rule, and the one beginners forget:


2. Deriving the Hamiltonian from scratch (Legendre transform)

HOW to derive HH and confirm it's a clean function of (q,p,t)(q,p,t). Start from a tiny change in LL:

dL=iLqidqi+iLq˙idq˙i+Ltdt.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.

Why this step? This is just the total differential — it lists how LL responds to changing each of its arguments.

Now use the definition pi=L/q˙ip_i = \partial L/\partial\dot q_i and the Euler–Lagrange equation ddtLq˙i=Lqi\dfrac{d}{dt}\dfrac{\partial L}{\partial \dot q_i} = \dfrac{\partial L}{\partial q_i}, i.e. p˙i=L/qi\dot p_i = \partial L/\partial q_i:

dL=ip˙idqi+ipidq˙i+Ltdt.dL = \sum_i \dot p_i\,dq_i + \sum_i p_i\,d\dot q_i + \frac{\partial L}{\partial t}\,dt.

Why this step? We rewrote the awkward partials in terms of pip_i and p˙i\dot p_i, which are the variables we actually want.

The term pidq˙i\sum p_i\,d\dot q_i still contains the velocity differential we want to eliminate. Use the product rule to flip it:

ipidq˙i=d ⁣(ipiq˙i)iq˙idpi.\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.

Why this step? This is the crux of the Legendre trick: d(pq˙)=pdq˙+q˙dpd(p\dot q)=p\,d\dot q+\dot q\,dp, so we swap a dq˙d\dot q term for a dpdp term.

Substitute and rearrange:

d ⁣(ipiq˙iL  =  H  )=iq˙idpiip˙idqiLtdt.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.

Why this step? Moving dLdL to the left and grouping shows that the natural quantity whose differential involves only dpdp, dqdq, dtdt is precisely H=piq˙iLH=\sum p_i\dot q_i - L. Its differential contains no dq˙d\dot q — proof that HH is genuinely a function of (q,p,t)(q,p,t).


3. When is HH the total energy?

If VV does not depend on velocities, pi=L/q˙i=T/q˙ip_i=\partial L/\partial\dot q_i = \partial T/\partial\dot q_i, so

ipiq˙i=iq˙iTq˙i=2T,\sum_i p_i\dot q_i = \sum_i \dot q_i\frac{\partial T}{\partial\dot q_i} = 2T,

hence

H=2TL=2T(TV)=T+V=E.H = 2T - L = 2T - (T - V) = T + V = E.

4. Worked examples


5. Flashcards

What is the conjugate momentum pip_i in terms of LL?
pi=L/q˙ip_i=\partial L/\partial\dot q_i
State the definition of the Hamiltonian.
H=ipiq˙iLH=\sum_i p_i\dot q_i - L, then expressed as H(q,p,t)H(q,p,t).
After writing H=piq˙iLH=\sum p_i\dot q_i - L, what MUST you do next?
Eliminate all q˙i\dot q_i by inverting pi=L/q˙ip_i=\partial L/\partial\dot q_i, so HH depends only on (q,p,t)(q,p,t).
What mathematical operation turns LL into HH?
A Legendre transform with respect to the velocities q˙i\dot q_i.
State Hamilton's canonical equations.
q˙i=H/pi\dot q_i=\partial H/\partial p_i and p˙i=H/qi\dot p_i=-\partial H/\partial q_i.
How many and what order are Hamilton's equations vs Euler–Lagrange?
2n2n first-order ODEs vs nn second-order ODEs.
Condition for HH to equal total energy T+VT+V?
TT homogeneous quadratic in q˙\dot q (no explicit-time/linear velocity terms) AND VV velocity-independent.
Condition for HH to be conserved?
H/t=0\partial H/\partial t=0, equivalently L/t=0\partial L/\partial t=0 (no explicit time dependence).
Why does piq˙i=2T\sum p_i\dot q_i=2T for natural systems?
Euler's theorem on the homogeneous quadratic TT in the q˙i\dot q_i.
Give a system where HH is conserved but HEH\ne E.
Bead on a uniformly rotating wire (time-dependent constraint).
What is H/t\partial H/\partial t in terms of LL?
H/t=L/t\partial H/\partial t=-\partial L/\partial 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=pq˙LH=p\dot 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.

Concept Map

define p = dL/dqdot

apply

gives H = sum p qdot minus L

invert to get qdot of q p

must

substitute

yields pdot

used in derivation

often equals

prevents

Lagrangian L of q qdot t

Conjugate momentum p

Legendre transform

Hamiltonian H

Eliminate qdot for p

H as function q p t

Euler-Lagrange eqn

pdot equals dL/dq

Total energy conserved

Mistake: leaving qdot in H

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, Lagrangian mechanics mein hum system ko coordinate qq aur velocity q˙\dot q se describe karte hain. Hamiltonian ka idea simple hai: velocity ki jagah hum momentum pp 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=piq˙iLH=\sum p_i\dot q_i - L.

Sabse important baat — jo students bhool jaate hain — yeh hai ki HH likhne ke baad usme se saare q˙\dot q hatana zaroori hai. Pehle pi=L/q˙ip_i=\partial L/\partial\dot q_i se q˙\dot q ko pp ke terms mein invert karo, phir substitute karo. Tabhi HH sahi maayne mein sirf (q,p,t)(q,p,t) ka function banta hai. Agar q˙\dot q andar reh gaya toh answer galat hai.

HH kab energy ke barabar hota hai? Jab kinetic energy TT velocity mein purely quadratic ho aur potential VV velocity pe depend na kare. Tab Euler's theorem se pq˙=2T\sum p\dot q = 2T, aur H=2TL=T+V=EH = 2T - L = T+V = E. Lekin yaad rakho: rotating wire jaise time-dependent constraint waale problems mein HEH\ne E ho sakta hai, phir bhi HH conserved reh sakta hai agar L/t=0\partial L/\partial t=0. Conservation aur "H=EH=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 aur p˙=H/q\dot p=-\partial H/\partial q. Yeh first-order equations second-order Euler–Lagrange ki jagah le lete hain, aur phase space (q,p)(q,p) mein motion ki picture bahut clean ho jaati hai.

Go deeper — visual, from zero

Test yourself — Analytical Mechanics

Connections