Lagrangian Mechanics

4 hours ~8 min read
Prerequisites

Lagrangian Mechanics

Newton tells you what happens at each instant: add up the forces, divide by the mass. Lagrange asks a stranger, deeper question: of all conceivable histories between two fixed moments, which one does nature actually choose? The answer — the path of stationary action — eliminates constraint forces, hands out conservation laws, and (as Feynman later showed) is the shadow of a quantum sum over every path at once. A cat stalking a sunbeam knew it all along.

Learning Objectives

After this lesson you will be able to:

  1. Reformulate mechanical problems in generalized coordinates, counting degrees of freedom and bypassing constraint forces.
  2. Derive the Euler–Lagrange equation from stationarity of the action S=LdtS = \int L\,dt via the calculus of variations.
  3. Construct Lagrangians L=TVL = T - V and obtain equations of motion for the oscillator, the pendulum, and central potentials.
  4. Identify cyclic coordinates and extract conserved conjugate momenta — Noether's theorem in miniature.
  5. Explain why the action controls quantum amplitudes through the phase eiS/e^{iS/\hbar} and the stationary-phase argument.

Intuition

Newtonian mechanics is local and forceful: at every instant, tally the forces and integrate. It works, but for constrained systems it makes you compute forces you never cared about — the tension in a pendulum rod, the normal force from a wire — just to eliminate them again.

The Lagrangian view is global and economical. Assign every conceivable path q(t)q(t) between fixed endpoints a single number, the action S[q]S[q]. The physical path is the one where SS is stationary: wiggling the path changes SS only at second order. Constraint forces never appear (they do no work along allowed motions), any convenient coordinates work, and symmetries hand you conservation laws. Quantum mechanics will explain why nature grades paths this way: every path contributes an amplitude of phase S/S/\hbar, and only near the stationary path do the phases agree and add up.


Theory

Newton in one paragraph

For a particle of mass mm, Newton's second law is mr¨=Fm\ddot{\mathbf r} = \mathbf F. A force is conservative if F=V\mathbf F = -\nabla V for some potential V(r)V(\mathbf r); then energy is conserved: $\frac{d}{dt}\big(\tfrac12 m\dot{\mathbf r}^2\big) = m\ddot{\mathbf r}\cdot\dot{\mathbf r} = -\nabla V\cdot\dot{\mathbf r} = -\frac{dV}{dt},so, so \frac{d}{dt}(T + V) = 0$. This framework is complete in principle — the trouble is practical.

Where Newton gets awkward

A pendulum bob in Cartesian coordinates obeys mr¨=mg+Trodm\ddot{\mathbf r} = m\mathbf g + \mathbf T_{\text{rod}}, where the rod tension Trod\mathbf T_{\text{rod}} is an unknown constraint force: you must solve for it and then eliminate it, even though the motion is fully described by one angle θ\theta. A bead on a bent wire is worse — the normal force changes direction along the wire. Newton forces you to (i) carry unknown constraint forces and (ii) work in coordinates that ignore the geometry. Both problems have one cure.

Generalized coordinates

A holonomic constraint is a relation f(r1,,rN,t)=0f(\mathbf r_1, \dots, \mathbf r_N, t) = 0 among coordinates. A system of NN particles with kk independent holonomic constraints has n=3Nkn = 3N - k degrees of freedom, and can be described by nn independent generalized coordinates q1,,qnq_1, \dots, q_n — any variables that smoothly parametrize the allowed configurations: the pendulum's θ\theta (n=1n = 1), arc length along the wire, two angles for a double pendulum. Velocities q˙i\dot q_i are their time derivatives; the pair (q,q˙)(q, \dot q) fixes the instantaneous state.

The action and the Euler–Lagrange equation

A functional assigns a number to a whole function. The action of a path q(t)q(t) between fixed endpoints q(t1)=qaq(t_1) = q_a, q(t2)=qbq(t_2) = q_b is

S[q]=t1t2L(q(t),q˙(t),t)dt, S[q] = \int_{t_1}^{t_2} L\big(q(t), \dot q(t), t\big)\,dt ,

with LL the Lagrangian. Hamilton's principle: the physical path makes SS stationary, δS=0\delta S = 0. To extract the consequence, deform the path: q(t)q(t)+ϵη(t)q(t) \to q(t) + \epsilon\,\eta(t) where η\eta is arbitrary and smooth with η(t1)=η(t2)=0\eta(t_1) = \eta(t_2) = 0 (endpoints pinned). Then S(ϵ)S(\epsilon) is an ordinary function, and stationarity means dS/dϵϵ=0=0dS/d\epsilon|_{\epsilon=0} = 0 for every η\eta. Differentiating under the integral with the chain rule,

dSdϵ0=t1t2(Lqη+Lq˙η˙)dt. \frac{dS}{d\epsilon}\bigg|_{0} = \int_{t_1}^{t_2}\left(\frac{\partial L}{\partial q}\,\eta + \frac{\partial L}{\partial\dot q}\,\dot\eta\right)dt .

Integrate the second term by parts:

t1t2Lq˙η˙dt=[Lq˙η]t1t2=0 since η(t1,2)=0t1t2ddt ⁣(Lq˙)ηdt, \int_{t_1}^{t_2}\frac{\partial L}{\partial\dot q}\,\dot\eta\,dt = \underbrace{\left[\frac{\partial L}{\partial\dot q}\,\eta\right]_{t_1}^{t_2}}_{=\,0 \text{ since } \eta(t_{1,2})=0} - \int_{t_1}^{t_2}\frac{d}{dt}\!\left(\frac{\partial L}{\partial\dot q}\right)\eta\,dt ,

so that

dSdϵ0=t1t2[Lqddt ⁣(Lq˙)]η(t)dt=0for all admissible η. \frac{dS}{d\epsilon}\bigg|_0 = \int_{t_1}^{t_2}\left[\frac{\partial L}{\partial q} - \frac{d}{dt}\!\left(\frac{\partial L}{\partial\dot q}\right)\right]\eta(t)\,dt = 0 \quad\text{for all admissible }\eta .

Now the fundamental lemma of the calculus of variations: if t1t2M(t)η(t)dt=0\int_{t_1}^{t_2} M(t)\eta(t)\,dt = 0 for every smooth η\eta vanishing at the endpoints, and MM is continuous, then M0M \equiv 0. (If M(t)>0M(t^*) > 0, continuity gives an interval where M>0M > 0; a smooth positive bump η\eta supported there makes the integral positive — contradiction.) Hence

  ddt ⁣(Lq˙i)Lqi=0  i=1,,n, \boxed{\;\frac{d}{dt}\!\left(\frac{\partial L}{\partial\dot q_i}\right) - \frac{\partial L}{\partial q_i} = 0\;} \qquad i = 1, \dots, n,

one Euler–Lagrange equation per coordinate (for several qiq_i, vary each independently).

Caution. In L/q˙\partial L/\partial\dot q, the symbols qq and q˙\dot q are independent slots of the function L(q,q˙,t)L(q, \dot q, t): differentiate treating q˙\dot q as a variable in its own right, then evaluate along the trajectory. Only the outer d/dtd/dt is a total derivative along the motion. Conflating the two is the single most common Lagrangian error.

L=TVL = T - V recovers Newton

For a particle in a conservative potential, take L=TV=12mr˙2V(r)L = T - V = \tfrac12 m\dot{\mathbf r}^2 - V(\mathbf r). Then L/x˙i=mx˙i\partial L/\partial\dot x_i = m\dot x_i and L/xi=V/xi\partial L/\partial x_i = -\partial V/\partial x_i, so Euler–Lagrange gives mx¨i=V/xim\ddot x_i = -\partial V/\partial x_i — exactly mr¨=Vm\ddot{\mathbf r} = -\nabla V. Hamilton's principle with L=TVL = T - V is Newtonian mechanics, repackaged.

Caution. L=TVL = T - V is not a law of nature. It holds for velocity-independent potentials; a charged particle in a magnetic field needs the generalized potential L=12mv2qϕ+qvAL = \tfrac12 m\mathbf v^2 - q\phi + q\,\mathbf v\cdot\mathbf A, and dissipative forces like friction have no Lagrangian at all. What survives universally is Hamilton's principle itself — with the appropriate LL.

Three worked systems

Harmonic oscillator. L=12mx˙212kx2L = \tfrac12 m\dot x^2 - \tfrac12 kx^2. Euler–Lagrange: ddt(mx˙)=kx\frac{d}{dt}(m\dot x) = -kx, i.e. x¨=ω2x\ddot x = -\omega^2 x with ω=k/m\omega = \sqrt{k/m}; solution x=Acos(ωt+φ)x = A\cos(\omega t + \varphi).

Simple pendulum (length \ell, mass mm). One generalized coordinate θ\theta: x=sinθx = \ell\sin\theta, y=cosθy = -\ell\cos\theta, so T=12m2θ˙2T = \tfrac12 m\ell^2\dot\theta^2 and V=mgcosθV = -mg\ell\cos\theta:

L=12m2θ˙2+mgcosθm2θ¨=mgsinθθ¨=gsinθ. L = \tfrac12 m\ell^2\dot\theta^2 + mg\ell\cos\theta \quad\Longrightarrow\quad m\ell^2\ddot\theta = -mg\ell\sin\theta \quad\Longrightarrow\quad \ddot\theta = -\frac{g}{\ell}\sin\theta .

This is the exact equation — no rod tension ever appeared. For small angles sinθθ\sin\theta \approx \theta and the pendulum is an oscillator with ω=g/\omega = \sqrt{g/\ell}.

Particle in a central potential (plane polar coordinates r,θr, \theta). With T=12m(r˙2+r2θ˙2)T = \tfrac12 m(\dot r^2 + r^2\dot\theta^2),

L=12m(r˙2+r2θ˙2)V(r):mr¨=mrθ˙2V(r),ddt(mr2θ˙)=0. L = \tfrac12 m\big(\dot r^2 + r^2\dot\theta^2\big) - V(r): \qquad m\ddot r = mr\dot\theta^2 - V'(r), \qquad \frac{d}{dt}\big(mr^2\dot\theta\big) = 0 .

The θ\theta equation says pθ=mr2θ˙p_\theta = mr^2\dot\theta is conserved — the angular momentum (this is Kepler's second law: equal areas in equal times). This conserved pθp_\theta is the seed of the quantum theory of angular momentum in P.6.1.

Cyclic coordinates and conservation

Define the conjugate (canonical) momentum pi=L/q˙ip_i = \partial L/\partial\dot q_i. If LL does not depend on some qjq_j — a cyclic coordinate — Euler–Lagrange collapses to p˙j=0\dot p_j = 0: the conjugate momentum of a cyclic coordinate is conserved. Free particle: xx cyclic, p=mx˙p = m\dot x conserved. Central potential: θ\theta cyclic, pθp_\theta conserved. This is Noether's theorem in its simplest form — each continuous symmetry of LL (here, invariance under shifting qjq_j) produces a conservation law. In quantum mechanics the same logic returns as "observables commuting with the Hamiltonian are conserved" (1.1.3).

Why the action matters for quantum mechanics

Feynman's path-integral formulation of quantum mechanics (plain statement — the machinery comes much later): a quantum particle going from aa to bb takes every path, and each path contributes a complex amplitude of unit magnitude and phase S[path]/S[\text{path}]/\hbar; the total amplitude is pathseiS/\sum_{\text{paths}} e^{iS/\hbar}. When SS \gg \hbar, the phase spins wildly as the path is deformed, and contributions from neighboring paths cancel — except near a path where SS is stationary, where nearby paths share the same phase and interfere constructively. Classical mechanics is the stationary-phase limit of quantum mechanics: Hamilton's principle is not an axiom but an interference pattern. Note \hbar has units of action (J·s) — it is precisely the scale that decides whether SS counts as "large". The waves being superposed here are amplitudes over paths, the same superposition logic as P.1.1.


Worked Examples

Example 1 — Atwood's machine

Masses m1=3.00m_1 = 3.00 kg and m2=5.00m_2 = 5.00 kg hang from an inextensible string over a massless, frictionless pulley. One degree of freedom: let xx be the downward displacement of m2m_2 (so m1m_1 rises by xx). Then T=12(m1+m2)x˙2T = \tfrac12(m_1 + m_2)\dot x^2 and V=m2gx+m1gxV = -m_2gx + m_1gx, so

L=12(m1+m2)x˙2+(m2m1)gx(m1+m2)x¨=(m2m1)g. L = \tfrac12(m_1 + m_2)\dot x^2 + (m_2 - m_1)gx \quad\Longrightarrow\quad (m_1 + m_2)\ddot x = (m_2 - m_1)g .

Hence x¨=g(m2m1)/(m1+m2)=9.81×2.00/8.00=2.45\ddot x = g(m_2 - m_1)/(m_1 + m_2) = 9.81 \times 2.00/8.00 = 2.45 m/s². The string tension — which Newton's approach must introduce and eliminate — never appeared. (If wanted afterwards: Tstr=m1(g+x¨)=36.8T_{\text{str}} = m_1(g + \ddot x) = 36.8 N.)

Example 2 — Bead on a uniformly rotating wire

A bead slides without friction on a straight horizontal wire forced to rotate at constant angular speed Ω\Omega about a vertical axis. Using the distance rr from the axis, the bead's position is (rcosΩt, rsinΩt)(r\cos\Omega t,\ r\sin\Omega t), so T=12m(r˙2+r2Ω2)T = \tfrac12 m(\dot r^2 + r^2\Omega^2) and V=0V = 0: L=12m(r˙2+Ω2r2)L = \tfrac12 m(\dot r^2 + \Omega^2 r^2). Euler–Lagrange: mr¨=mΩ2rm\ddot r = m\Omega^2 r, i.e. r¨=Ω2r\ddot r = \Omega^2 r — the "centrifugal" term emerged automatically from the kinematics. With r(0)=r0r(0) = r_0, r˙(0)=0\dot r(0) = 0: r(t)=r0cosh(Ωt)r(t) = r_0\cosh(\Omega t). For Ω=2.00\Omega = 2.00 rad/s, r0=0.100r_0 = 0.100 m: r(1s)=0.100cosh2=0.376r(1\,\text{s}) = 0.100\cosh 2 = 0.376 m — the bead is flung outward. Its kinetic energy grows (the motor turning the wire does work): energy is not conserved here, a subtlety the Hamiltonian framework will diagnose cleanly in P.1.3.


Hands-on (Python)

import numpy as np

# --- The true path is stationary: discretized action for the oscillator ---
# m = k = 1, endpoints x(0) = 0, x(Tf) = 1 with Tf = 1 (< pi => a minimum).
# True solution of xdd = -x through these endpoints: x(t) = sin(t)/sin(1).
m = k = 1.0; Tf = 1.0; N = 2001
t = np.linspace(0.0, Tf, N); dt = t[1] - t[0]

def action(x):
    v  = np.diff(x)/dt                   # velocities on interval midpoints
    xm = 0.5*(x[1:] + x[:-1])            # positions on interval midpoints
    return np.sum(0.5*m*v**2 - 0.5*k*xm**2)*dt

x_true = np.sin(t)/np.sin(1.0)
S0 = action(x_true)
print(f"S_true = {S0:.4f}")              # 0.3210  (analytic: sin(2)/(4 sin^2 1))

# one random smooth perturbation, exactly zero at both endpoints:
rng = np.random.default_rng(0)
modes = np.arange(1, 6)
eta = (rng.normal(size=5)[:, None]*np.sin(np.outer(modes, np.pi*t/Tf))).sum(0)
for eps in (0.01, 0.05, 0.10, 0.20):
    dS = action(x_true + eps*eta) - S0
    print(f"eps = {eps:4.2f}   S - S_true = {dS:+.6f}   dS/eps^2 = {dS/eps**2:.3f}")
# Expected: every dS > 0 and dS/eps^2 = 27.268 for ALL eps -- the first-order
# variation vanishes identically: the true path is stationary (here a minimum).
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp

# --- Full pendulum vs small-angle solution ---
g, ell = 9.81, 1.0
w0 = np.sqrt(g/ell)                       # small-angle frequency, period 2.006 s
rhs = lambda t, y: [y[1], -(g/ell)*np.sin(y[0])]

t = np.linspace(0, 10, 2000)
fig, axes = plt.subplots(2, 1, figsize=(8, 6))
for th0, ax in zip((0.10, 2.50), axes):
    sol = solve_ivp(rhs, (0, 10), [th0, 0.0], t_eval=t, rtol=1e-9)
    ax.plot(t, sol.y[0], label="exact")
    ax.plot(t, th0*np.cos(w0*t), "--", label="small-angle")
    ax.set(title=f"theta0 = {th0} rad", ylabel="theta (rad)"); ax.legend()
axes[1].set_xlabel("t (s)"); plt.tight_layout(); plt.show()
# Expected: theta0 = 0.10 -> the two curves are indistinguishable.
# theta0 = 2.50 -> exact period ~ 3.29 s (elliptic integral), so the exact
# curve drifts steadily out of phase with the 2.006 s small-angle cosine.

Exercises

E1 (easy). Write the Lagrangian of a projectile in a vertical plane, L=12m(x˙2+y˙2)mgyL = \tfrac12 m(\dot x^2 + \dot y^2) - mgy, derive both equations of motion, and identify the conserved momentum.

Solution

Euler–Lagrange: ddt(mx˙)=0\frac{d}{dt}(m\dot x) = 0 and ddt(my˙)=mg\frac{d}{dt}(m\dot y) = -mg, i.e. x¨=0\ddot x = 0, y¨=g\ddot y = -g — projectile motion. xx is cyclic, so px=mx˙p_x = m\dot x is conserved (horizontal translation symmetry).

E2 (easy). A mass hangs from a vertical spring; let xx be the downward displacement from the spring's natural length, so L=12mx˙212kx2+mgxL = \tfrac12 m\dot x^2 - \tfrac12 kx^2 + mgx. Find the motion.

Solution

Euler–Lagrange: mx¨=kx+mgm\ddot x = -kx + mg. Substituting u=xmg/ku = x - mg/k: mu¨=kum\ddot u = -ku — simple harmonic motion at ω=k/m\omega = \sqrt{k/m} about the shifted equilibrium xeq=mg/kx_{\text{eq}} = mg/k. Gravity relocates the center of oscillation but leaves the frequency alone.

E3 (medium). Show that L=L+dFdtL' = L + \frac{dF}{dt} for any smooth F(q,t)F(q, t) yields the same Euler–Lagrange equations as LL.

Solution

S[q]=S[q]+t1t2dFdtdt=S[q]+F(qb,t2)F(qa,t1)S'[q] = S[q] + \int_{t_1}^{t_2}\frac{dF}{dt}\,dt = S[q] + F(q_b, t_2) - F(q_a, t_1). The added term depends only on the fixed endpoints, so it is the same constant for every admissible path: δS=δS\delta S' = \delta S, and the stationary paths — hence the equations of motion — coincide. The Lagrangian of a given system is therefore not unique (a "gauge" freedom).

E4 (medium). Use the Euler–Lagrange equation to prove the shortest path between two points in a plane is a straight line, starting from the arc-length functional J[y]=x1x21+y2dxJ[y] = \int_{x_1}^{x_2}\sqrt{1 + y'^2}\,dx.

Solution

Here xx plays "time" and L(y,y)=1+y2L(y, y') = \sqrt{1 + y'^2} has no explicit yy: yy is cyclic, so L/y=y/1+y2\partial L/\partial y' = y'/\sqrt{1 + y'^2} is constant. That forces y=consty' = \text{const}, i.e. y=ax+by = ax + b — a straight line. The variational machinery is indifferent to what the independent variable means physically.

E5 (hard). A block of mass mm slides on the frictionless face (angle α\alpha) of a wedge of mass MM that itself slides on a frictionless floor. Find the accelerations of both.

Solution

Coordinates: wedge position XX; block displacement ss down the incline. The block's position is (X+scosα, hssinα)(X + s\cos\alpha,\ h - s\sin\alpha), so

T=12MX˙2+12m[(X˙+s˙cosα)2+s˙2sin2α],V=mgssinα. T = \tfrac12 M\dot X^2 + \tfrac12 m\big[(\dot X + \dot s\cos\alpha)^2 + \dot s^2\sin^2\alpha\big], \qquad V = -mgs\sin\alpha .

XX is cyclic: ddt[(M+m)X˙+ms˙cosα]=0\frac{d}{dt}\big[(M + m)\dot X + m\dot s\cos\alpha\big] = 0 (total horizontal momentum), so (M+m)X¨=ms¨cosα(M+m)\ddot X = -m\ddot s\cos\alpha. The ss equation: m(s¨+X¨cosα)=mgsinαm(\ddot s + \ddot X\cos\alpha) = mg\sin\alpha. Substituting X¨\ddot X:

s¨=(M+m)gsinαM+msin2α,X¨=mgsinαcosαM+msin2α. \ddot s = \frac{(M + m)g\sin\alpha}{M + m\sin^2\alpha}, \qquad \ddot X = -\frac{mg\sin\alpha\cos\alpha}{M + m\sin^2\alpha}.

Checks: MM \to \infty gives s¨gsinα\ddot s \to g\sin\alpha, X¨0\ddot X \to 0 ✓. For M=2.00M = 2.00 kg, m=1.00m = 1.00 kg, α=30°\alpha = 30°: s¨=6.54\ddot s = 6.54 m/s², X¨=1.89\ddot X = -1.89 m/s². Two Newtonian constraint forces (normal forces on two surfaces) were never computed.


Checkpoint

  1. What is a generalized coordinate, and which two Newtonian headaches does it cure?
  2. Sketch the derivation of the Euler–Lagrange equation. Where exactly is η(t1)=η(t2)=0\eta(t_1) = \eta(t_2) = 0 used?
  3. When is L=TVL = T - V valid, and what is a standard counterexample?
  4. What is a cyclic coordinate, and what conservation law follows? Give two examples.
  5. In the path-integral picture, why do classical paths dominate when SS \gg \hbar?
Answers
  1. Any variable smoothly parametrizing allowed configurations (one per degree of freedom). It eliminates constraint forces and lets you work in coordinates adapted to the geometry.
  2. Perturb qq+ϵηq \to q + \epsilon\eta, expand SS to first order, integrate the η˙\dot\eta term by parts, and invoke the fundamental lemma. The endpoint conditions kill the boundary term [(L/q˙)η]t1t2[\,(\partial L/\partial\dot q)\eta\,]_{t_1}^{t_2} from the integration by parts.
  3. For velocity-independent (conservative) potentials. Counterexample: magnetic forces, which need L=12mv2qϕ+qvAL = \tfrac12 m\mathbf v^2 - q\phi + q\mathbf v\cdot\mathbf A; friction has no Lagrangian.
  4. A coordinate absent from LL; its conjugate momentum p=L/q˙p = \partial L/\partial\dot q is conserved. Free particle (xx → linear momentum); central potential (θ\theta → angular momentum mr2θ˙mr^2\dot\theta).
  5. Each path contributes eiS/e^{iS/\hbar}; away from stationary points of SS the phase varies rapidly between neighboring paths and contributions cancel, while paths near the stationary (classical) one share a phase and add constructively.

Further Reading

  • [Gold] Goldstein, Poole & Safko, Ch. 1–2 — constraints, generalized coordinates, and variational principles; the definitive treatment.
  • [Sha] Shankar, §2.1 — the principle of least action, written with quantization in mind.
  • [Sak] Sakurai & Napolitano, §2.6 — propagators and Feynman path integrals: eiS/e^{iS/\hbar} made precise.

← Prev: Waves & the Wave Equation · Up: Pre-Term · Next: Hamiltonian Mechanics

Ready to measure your state?

5 exercises · 10 checkpoint questions

Start the quiz