MathLabs

Mathematical physics

Lagrangian and Hamiltonian mechanics

Rewriting Newton's laws in terms of energy and generalized coordinates: the principle of stationary action, the Euler–Lagrange and Hamilton equations, and how symmetries force conservation laws.

IntuitionFrom forces to a single scalar: the idea of least action

Newton's second law F=maF=ma needs one vector equation per particle, in whatever coordinates make the forces easy to write down — awkward for a pendulum, where the string tension is a constraint force we would rather not compute at all. Lagrangian mechanics replaces force bookkeeping with a single scalar, the Lagrangian L=T−VL = T - V (kinetic minus potential energy), written in whatever coordinates describe the system's genuine freedom to move — its generalized coordinates. Nature, remarkably, behaves as if it makes stationary the accumulated value of LL over time: the action.

A point on the unit circle at angle theta measured from the bottom (downward vertical), representing the bob of a pendulum of length ℓ hanging at angle θ from straight down.
A pendulum of length ℓ\ell swinging to angle θ\theta from the vertical. One number, θ\theta, is enough to describe the pendulum's position — that is its generalized coordinate.

UndergraduateGeneralized coordinates and the Lagrangian

Definition: Generalized coordinates and the Lagrangian

For a system whose configuration is described by coordinates q=(q1,…,qn)q = (q_1,\dots,q_n) (which need not be Cartesian — an angle, an arc length, anything that fixes the configuration), the Lagrangian is L(q,q˙,t)=T(q,q˙)−V(q)L(q,\dot q, t) = T(q,\dot q) - V(q), kinetic energy minus potential energy, both expressed in terms of qq and the generalized velocities q˙\dot q.

The action of a path q(t)q(t) from time t1t_1 to t2t_2 is S[q]=∫t1t2L(q(t),q˙(t),t) dtS[q] = \int_{t_1}^{t_2} L(q(t), \dot q(t), t)\, dt. Hamilton's principle (the principle of stationary action) says: the path the system actually follows makes SS stationary among all paths with the same endpoints.

ddt∂L∂q˙k−∂L∂qk=0\frac{d}{dt}\frac{\partial L}{\partial \dot q_k} - \frac{\partial L}{\partial q_k} = 0

A path q(t)q(t) makes the action S[q]=∫t1t2L(q,q˙,t) dtS[q]=\int_{t_1}^{t_2}L(q,\dot q,t)\,dt stationary, with fixed endpoints, if and only if, for every coordinate qkq_k, ddt∂L∂q˙k−∂L∂qk=0\dfrac{d}{dt}\dfrac{\partial L}{\partial \dot q_k} - \dfrac{\partial L}{\partial q_k} = 0.

Why is it true?

Perturb the path by q(t)+ϵ η(t)q(t)+\epsilon\,\eta(t) with η(t1)=η(t2)=0\eta(t_1)=\eta(t_2)=0 and require ddϵS[q+ϵη]∣ϵ=0=0\frac{d}{d\epsilon}S[q+\epsilon\eta]\big|_{\epsilon=0}=0 for every such η\eta. Expanding to first order in ϵ\epsilon and integrating the η˙\dot\eta term by parts (the boundary term vanishes because η(t1)=η(t2)=0\eta(t_1)=\eta(t_2)=0) leaves ∫(∂L∂qk−ddt∂L∂q˙k)ηk dt=0\int \left(\frac{\partial L}{\partial q_k} - \frac{d}{dt}\frac{\partial L}{\partial \dot q_k}\right)\eta_k\,dt = 0 for every η\eta, which forces the bracket to vanish identically.

Proof

Step 1 (set up the variation). Let q(t)q(t) be the true path and perturb it by q(t)+ϵ η(t)q(t)+\epsilon\,\eta(t) for a small parameter ϵ\epsilon, where η(t)\eta(t) is an arbitrary smooth function satisfying η(t1)=η(t2)=0\eta(t_1)=\eta(t_2)=0 so the perturbed path shares the same endpoints as q(t)q(t). Hamilton's principle requires S[q+ϵη]S[q+\epsilon\eta] to be stationary at ϵ=0\epsilon=0 for every admissible η\eta, i.e. ddϵS[q+ϵη]∣ϵ=0=0\frac{d}{d\epsilon}S[q+\epsilon\eta]\big|_{\epsilon=0}=0.

Step 2 (differentiate under the integral). Differentiating S[q+ϵη]=∫t1t2L(q+ϵη,q˙+ϵη˙,t) dtS[q+\epsilon\eta]=\int_{t_1}^{t_2}L(q+\epsilon\eta,\dot q+\epsilon\dot\eta,t)\,dt with respect to ϵ\epsilon and setting ϵ=0\epsilon=0 gives, by the chain rule applied term by term, ddϵS[q+ϵη]∣ϵ=0=∫t1t2∑k(∂L∂qkηk+∂L∂q˙kη˙k)dt\frac{d}{d\epsilon}S[q+\epsilon\eta]\Big|_{\epsilon=0}=\int_{t_1}^{t_2}\sum_k\left(\frac{\partial L}{\partial q_k}\eta_k+\frac{\partial L}{\partial \dot q_k}\dot\eta_k\right)dt

**Step 3 (integrate the η˙k\dot\eta_k term by parts).** For each kk, integration by parts turns ∫t1t2∂L∂q˙kη˙k dt\int_{t_1}^{t_2}\frac{\partial L}{\partial \dot q_k}\dot\eta_k\,dt into a boundary term minus a bulk term: ∫t1t2∂L∂q˙kη˙k dt=[∂L∂q˙kηk]t1t2−∫t1t2ddt(∂L∂q˙k)ηk dt\int_{t_1}^{t_2}\frac{\partial L}{\partial \dot q_k}\dot\eta_k\,dt = \left[\frac{\partial L}{\partial \dot q_k}\eta_k\right]_{t_1}^{t_2} - \int_{t_1}^{t_2}\frac{d}{dt}\left(\frac{\partial L}{\partial \dot q_k}\right)\eta_k\,dt

Step 4 (the boundary term vanishes). Because [∂L∂q˙kηk]t1t2=0\left[\frac{\partial L}{\partial \dot q_k}\eta_k\right]_{t_1}^{t_2}=0 by the fixed-endpoint condition η(t1)=η(t2)=0\eta(t_1)=\eta(t_2)=0, only the bulk integral survives, and substituting back into Step 2 gives ∫t1t2∑k(∂L∂qk−ddt∂L∂q˙k)ηk(t) dt=0\int_{t_1}^{t_2}\sum_k\left(\frac{\partial L}{\partial q_k}-\frac{d}{dt}\frac{\partial L}{\partial \dot q_k}\right)\eta_k(t)\,dt=0

Step 5 (fundamental lemma of the calculus of variations). This integral vanishes for every smooth ηk\eta_k vanishing at the endpoints. If the bracket ∂L∂qk−ddt∂L∂q˙k\frac{\partial L}{\partial q_k}-\frac{d}{dt}\frac{\partial L}{\partial \dot q_k} were nonzero and continuous at some interior point t0t_0, it would keep a fixed sign on some small interval around t0t_0; choosing ηk\eta_k to be a smooth bump function supported on that interval (positive where the bracket is positive, and zero elsewhere) would make the integral strictly nonzero, a contradiction. Hence the bracket must vanish identically, giving ddt∂L∂q˙k−∂L∂qk=0\frac{d}{dt}\frac{\partial L}{\partial \dot q_k} - \frac{\partial L}{\partial q_k} = 0 for every kk — the Euler–Lagrange equation.

Example: The pendulum, the Lagrangian way

A bob of mass mm hangs from a rigid, massless rod of length ℓ\ell in a uniform gravitational field gg, free to swing in a vertical plane; θ\theta is the angle from the downward vertical.

Solution

Position: x=ℓsin⁡θx=\ell\sin\theta, y=−ℓcos⁡θy=-\ell\cos\theta, so x˙2+y˙2=ℓ2θ˙2\dot x^2+\dot y^2 = \ell^2\dot\theta^2. Kinetic energy T=12mℓ2θ˙2T=\tfrac12 m\ell^2\dot\theta^2; potential energy (measuring from the pivot) V=−mgℓcos⁡θV=-mg\ell\cos\theta. So L=12mℓ2θ˙2+mgℓcos⁡θL=\tfrac12 m\ell^2\dot\theta^2+mg\ell\cos\theta. Euler–Lagrange: ddt(mℓ2θ˙)−(−mgℓsin⁡θ)=0\frac{d}{dt}(m\ell^2\dot\theta) - (-mg\ell\sin\theta) = 0, i.e. θ¨+gℓsin⁡θ=0\ddot\theta + \frac{g}{\ell}\sin\theta = 0 — the pendulum equation, obtained without ever computing the string tension.

UndergraduateSymmetry forces conservation: Noether's theorem

If a system's Lagrangian does not change under some continuous transformation of the coordinates — a symmetry — something is conserved along every actual trajectory. Rotating a system with no preferred direction does not change its Lagrangian, and that symmetry is exactly why angular momentum is conserved for such a system; likewise a Lagrangian with no explicit time-dependence has time-translation symmetry, which is exactly why energy is conserved.

If the Lagrangian LL is invariant under a continuous one-parameter family of transformations qk↦qk(s)q_k \mapsto q_k(s), qk(0)=qkq_k(0)=q_k, then the quantity I=∑k∂L∂q˙kdqk(s)ds∣s=0I = \sum_k \dfrac{\partial L}{\partial \dot q_k}\left.\dfrac{d q_k(s)}{ds}\right|_{s=0} is conserved along every solution of the Euler–Lagrange equations.

Why is it true?

Differentiating L(q(s),q˙(s),t)=L(q,q˙,t)L(q(s),\dot q(s),t)=L(q,\dot q,t) (invariance) with respect to ss at s=0s=0 and using the Euler–Lagrange equations to rewrite ∂L/∂qk\partial L/\partial q_k as ddt(∂L/∂q˙k)\frac{d}{dt}\left(\partial L/\partial \dot q_k\right) turns the result into ddt∑k∂L∂q˙k∂qk∂s=0\frac{d}{dt}\sum_k \frac{\partial L}{\partial \dot q_k}\frac{\partial q_k}{\partial s}=0: exactly the statement that II has zero time derivative, i.e. is conserved.

Proof

Step 1 (differentiate the invariance identity). Invariance of LL under the transformation means L(q(s),q˙(s),t)=L(q,q˙,t)L(q(s),\dot q(s),t)=L(q,\dot q,t) holds identically in ss. Differentiating both sides with respect to ss and evaluating at s=0s=0 (using qk(0)=qkq_k(0)=q_k) gives, by the chain rule, ∑k(∂L∂qk∂qk∂s+∂L∂q˙k∂q˙k∂s)∣s=0=0\sum_k\left(\frac{\partial L}{\partial q_k}\frac{\partial q_k}{\partial s}+\frac{\partial L}{\partial \dot q_k}\frac{\partial \dot q_k}{\partial s}\right)\bigg|_{s=0}=0

Step 2 (use the Euler–Lagrange equation on the actual trajectory). Because q(t)q(t) solves the Euler–Lagrange equations, ∂L∂qk=ddt∂L∂q˙k\frac{\partial L}{\partial q_k}=\frac{d}{dt}\frac{\partial L}{\partial \dot q_k}. Substituting this into the first term of Step 1 replaces ∂L/∂qk\partial L/\partial q_k by a total time derivative.

**Step 3 (commute the ss- and tt-derivatives).** Since ss and tt are independent variables, mixed partial derivatives of qk(s,t)q_k(s,t) commute: ∂q˙k∂s=ddt∂qk∂s\frac{\partial \dot q_k}{\partial s}=\frac{d}{dt}\frac{\partial q_k}{\partial s}. This lets the second term of Step 1 be rewritten with a total time derivative as well.

Step 4 (recognize a total derivative). With both terms now built from ddt(⋅)\frac{d}{dt}(\cdot), the product rule runs in reverse: ddt∂L∂q˙k⋅∂qk∂s+∂L∂q˙k⋅ddt∂qk∂s=ddt(∂L∂q˙k∂qk∂s)\frac{d}{dt}\frac{\partial L}{\partial \dot q_k}\cdot\frac{\partial q_k}{\partial s}+\frac{\partial L}{\partial \dot q_k}\cdot\frac{d}{dt}\frac{\partial q_k}{\partial s}=\frac{d}{dt}\left(\frac{\partial L}{\partial \dot q_k}\frac{\partial q_k}{\partial s}\right). Substituting into the identity of Step 1 collapses it to a single total time derivative equal to zero: dIdt=ddt∑k∂L∂q˙k∂qk∂s∣s=0=0\frac{dI}{dt}=\frac{d}{dt}\sum_k\frac{\partial L}{\partial \dot q_k}\frac{\partial q_k}{\partial s}\bigg|_{s=0}=0

Step 5 (conclude conservation). A quantity whose time derivative vanishes identically along every solution of the equations of motion is constant along that solution. Hence I=∑k∂L∂q˙k∂qk∂s∣s=0I=\sum_k \frac{\partial L}{\partial \dot q_k}\frac{\partial q_k}{\partial s}\big|_{s=0} is conserved, which is Noether's theorem.

Example: Time invariance gives energy

If LL does not depend explicitly on tt (time-translation symmetry), Noether's theorem, with ss playing the role of a time shift, gives the conserved quantity H=∑kq˙k∂L∂q˙k−LH=\sum_k \dot q_k\dfrac{\partial L}{\partial \dot q_k} - L — for the systems considered here, exactly the total mechanical energy T+VT+V.

Solution

Step 1 (pick the symmetry). Time-translation is the one-parameter family qk(s)=qk(t+s)q_k(s)=q_k(t+s), i.e. shifting every point of the trajectory forward by ss; since LL has no explicit tt-dependence, L(q(t+s),q˙(t+s))=L(q(t),q˙(t))L(q(t+s),\dot q(t+s))=L(q(t),\dot q(t)) along the true motion, so this transformation leaves LL invariant in the sense Noether's theorem requires.

Step 2 (compute the generator). Differentiating qk(t+s)q_k(t+s) with respect to ss at s=0s=0 just gives back the velocity: ∂qk∂s∣s=0=q˙k\frac{\partial q_k}{\partial s}\Big|_{s=0}=\dot q_k.

Step 3 (plug into Noether's conserved quantity). Noether's theorem gives the conserved quantity I=∑k∂L∂q˙k∂qk∂s∣s=0I=\sum_k \frac{\partial L}{\partial \dot q_k}\frac{\partial q_k}{\partial s}\big|_{s=0}; substituting Step 2, I=∑k∂L∂q˙kq˙kI=\sum_k \frac{\partial L}{\partial \dot q_k}\dot q_k.

Step 4 (identify it as the Hamiltonian). Using the generalized momentum pk=∂L/∂q˙kp_k=\partial L/\partial \dot q_k, this conserved II is exactly H=∑kpkq˙k−LH=\sum_k p_k\dot q_k - L, i.e. H=∑kq˙k∂L∂q˙k−LH=\sum_k \dot q_k\frac{\partial L}{\partial \dot q_k} - L. For the mechanical systems here, L=T−VL=T-V with TT quadratic in q˙\dot q, so ∑kq˙k ∂L/∂q˙k=2T\sum_k \dot q_k\,\partial L/\partial \dot q_k = 2T and H=2T−(T−V)=T+VH=2T-(T-V)=T+V: total mechanical energy is conserved precisely because the Lagrangian does not depend explicitly on time.

AdvancedPhase space: Hamilton's equations

Definition: Generalized momentum and the Hamiltonian

The generalized momentum conjugate to qkq_k is pk=∂L/∂q˙kp_k = \partial L/\partial \dot q_k. Replacing the velocities q˙\dot q by the momenta pp (a Legendre transform) gives the Hamiltonian H(q,p,t)=∑kpkq˙k−LH(q,p,t) = \sum_k p_k \dot q_k - L, interpreted, for the systems considered here, as the total energy expressed in terms of position and momentum instead of position and velocity.

q˙k=∂H∂pk,p˙k=−∂H∂qk\dot q_k = \frac{\partial H}{\partial p_k}, \qquad \dot p_k = -\frac{\partial H}{\partial q_k}

These are Hamilton's equations: 2n2n first-order equations replacing the nn second-order Euler–Lagrange equations. A solution traces a curve through phase space, the 2n2n-dimensional space of pairs (q,p)(q,p); every point of phase space fixes the entire future (and past) of the system.

A saddle-shaped surface representing a potential energy landscape, curving upward along one horizontal axis (a stable direction) and downward along the perpendicular axis (an unstable direction), meeting at a flat saddle point in the middle that is an equilibrium but not an energy minimum.
A potential energy surface shaped like z=x2−y2z = x^2 - y^2: stable (bowl-like) along one direction, unstable along the other. The flat point at the centre is an equilibrium of the system, but not a minimum of the energy — small pushes in the unstable direction grow.

Let a region of phase space evolve under Hamilton's equations, each point (q(t),p(t))(q(t),p(t)) following its own trajectory. Then the volume of the region, with respect to the standard measure dq dpdq\,dp on phase space, is the same at every time tt.

Why is it true?

The phase-space velocity field (q˙,p˙)=(∂H/∂p,−∂H/∂q)(\dot q,\dot p) = (\partial H/\partial p, -\partial H/\partial q) is divergence-free: ∑k(∂q˙k∂qk+∂p˙k∂pk)=∑k(∂2H∂qk∂pk−∂2H∂pk∂qk)=0\sum_k\left(\frac{\partial \dot q_k}{\partial q_k}+\frac{\partial \dot p_k}{\partial p_k}\right) = \sum_k\left(\frac{\partial^2 H}{\partial q_k \partial p_k} - \frac{\partial^2 H}{\partial p_k \partial q_k}\right)=0, because mixed partial derivatives commute. A divergence-free flow preserves volume, by the same reasoning as the divergence theorem for an incompressible fluid.

Proof

Step 1 (the phase-space flow). Hamilton's equations (q˙,p˙)=(∂H∂p,−∂H∂q)(\dot q,\dot p)=\left(\frac{\partial H}{\partial p},-\frac{\partial H}{\partial q}\right) define a velocity field on phase space; every point (q,p)(q,p) moves along this field, so a region Ω(t1)\Omega(t_1) is carried by the flow to a region Ω(t2)\Omega(t_2). The Reynolds transport theorem gives the rate of change of the enclosed volume V(t)=∫Ω(t)dq dpV(t)=\int_{\Omega(t)}dq\,dp as the flux of the divergence: ddtV(t)=∫Ω(t)∇⋅(q˙,p˙) dq dp\frac{d}{dt}V(t)=\int_{\Omega(t)}\nabla\cdot(\dot q,\dot p)\,dq\,dp

Step 2 (compute the divergence). Directly from Hamilton's equations, ∑k(∂∂qk∂H∂pk+∂∂pk(−∂H∂qk))=∑k(∂2H∂qk∂pk−∂2H∂pk∂qk)=0\sum_k\left(\frac{\partial}{\partial q_k}\frac{\partial H}{\partial p_k}+\frac{\partial}{\partial p_k}\left(-\frac{\partial H}{\partial q_k}\right)\right)=\sum_k\left(\frac{\partial^2 H}{\partial q_k\partial p_k}-\frac{\partial^2 H}{\partial p_k\partial q_k}\right)=0 because mixed second partial derivatives of the smooth function HH commute (equality of mixed partials, Schwarz's theorem): ∂2H/∂qk∂pk=∂2H/∂pk∂qk\partial^2H/\partial q_k\partial p_k=\partial^2H/\partial p_k\partial q_k, so the two terms cancel exactly.

Step 3 (zero divergence forces zero rate of change). Substituting the Step 2 result into the transport formula of Step 1 gives ddtV(t)=0\frac{d}{dt}V(t)=0 at every instant tt, for every choice of initial region Ω(t1)\Omega(t_1).

Step 4 (integrate to get equal volumes). A function of tt whose derivative is identically zero is constant, so V(t)=V(t1)V(t)=V(t_1) for all tt: the phase-space volume of the evolving region never changes, exactly as claimed.

Liouville's theorem is what allows statistical mechanics to treat an ensemble of systems as an incompressible fluid flowing through phase space — the density of trajectories at a point never changes just from the flow squeezing or stretching space, only from probability actually moving in or out. It is also the starting point for the modern, coordinate-free formulation of Hamiltonian mechanics on symplectic manifolds, where Hamilton's equations become a single geometric statement and Liouville's theorem becomes the preservation of a canonical volume form.

AdvancedWhere this leads

The Hamiltonian formulation is the doorway from classical to quantum mechanics: replacing Poisson brackets (the algebraic structure underlying Hamilton's equations) with commutators of operators is one standard route to quantization. It is also the natural language for chaos and stability in dynamical systems, and its coordinate-free version is the subject of symplectic geometry.

For a pendulum of length ℓ\ell swinging under gravity, the Lagrangian is

Which symmetry of the Lagrangian does Noether's theorem link to conservation of energy?

Hamilton's equations replace the nn second-order Euler–Lagrange equations with

Liouville's theorem says that under Hamiltonian flow, a region of phase space

References

  1. Herbert Goldstein, Charles Poole, John Safko (2002). Classical Mechanics
  2. Lev D. Landau, Evgeny M. Lifshitz (1976). Mechanics · DOI:10.1146/annurev-conmatphys-031214-014726
  3. Emmy Noether (1918). Invariante Variationsprobleme · DOI:10.1515/dmvm-2011-0046