Lagrangian & Hamiltonian Mechanics
CollegeThe action principle
Newtonian mechanics works force by force; the Lagrangian formulation works with energy and a single scalar function, often making complex constrained systems far easier to solve. Choose generalized coordinates qi — any set that fixes the configuration (an angle, an arc length, whatever is natural) — and define the Lagrangian:
The true path a system follows makes the action S = ∫L dt stationary (Hamilton's principle) compared with all nearby paths. Applying the calculus of variations yields the Euler–Lagrange equation for each coordinate:
This single recipe reproduces ΣF = ma in Cartesian coordinates but also handles pendulums, orbits and constrained systems without ever writing down the constraint forces.
The Hamiltonian
Define the generalized momentum pᵢ = ∂L/∂q̇ᵢ and apply a Legendre transform to trade velocities for momenta:
For most physical systems H equals the total energy T + V. Hamilton's equations replace one second-order Euler–Lagrange equation per coordinate with two first-order equations:
Symmetry and conservation — Noether's theorem
Chapter 10's "deep idea" note observed that conservation laws come from symmetries. The Lagrangian formalism makes this precise. If L does not depend explicitly on a coordinate qᵢ (it is cyclic), the Euler–Lagrange equation immediately gives d/dt(∂L/∂q̇ᵢ) = 0 — the conjugate momentum pᵢ is conserved. A Lagrangian independent of position (translational symmetry) conserves linear momentum; independent of angle (rotational symmetry) conserves angular momentum; independent of time (time-translation symmetry) conserves the Hamiltonian, i.e. energy. This is Noether's theorem: every continuous symmetry of the action implies a conservation law, and vice versa.
The power of the method is coordinate freedom. A bead on a rotating hoop, a double pendulum, or a particle constrained to a curved surface are painful in F = ma (you must find every normal/constraint force), but trivial in Lagrangian form: pick coordinates that respect the constraint, write T − V, differentiate. The constraint forces never appear because they do no work along the constraint surface.
Worked example — the simple pendulum, two ways
A pendulum of length ℓ and bob mass m swings through angle θ(t). Derive its equation of motion via the Lagrangian, then find the Hamiltonian.
- Position:
x = ℓsinθ,y = −ℓcosθ. Speed:v² = ẋ² + ẏ² = ℓ²θ̇². - Kinetic energy:
T = ½mℓ²θ̇². Potential energy (measuring from the pivot):V = −mgℓcosθ. - Lagrangian:
L = T − V = ½mℓ²θ̇² + mgℓcosθ. - Euler–Lagrange:
∂L/∂θ̇ = mℓ²θ̇, sod/dt(mℓ²θ̇) = mℓ²θ̈. And∂L/∂θ = −mgℓsinθ. - Equation of motion:
mℓ²θ̈ − (−mgℓsinθ) = 0 ⟹ θ̈ = −(g/ℓ)sinθ— exactly Newton's result, obtained without ever drawing a tension force. - Generalized momentum:
pθ = mℓ²θ̇. Hamiltonian:H = pθθ̇ − L = ½mℓ²θ̇² − mgℓcosθ = T + V— the total mechanical energy, as expected, and it is conserved since∂L/∂t = 0.
For small angles, sinθ ≈ θ, giving θ̈ = −(g/ℓ)θ — simple harmonic motion with ω = √(g/ℓ), recovering Chapter 6's pendulum period T = 2π√(ℓ/g).
Why does the tension in the pendulum string never appear in the Lagrangian derivation?
Tension is a constraint force that acts exactly along the string, perpendicular to the bob's motion (which is tangential), so it does no work and has no component along the generalized coordinate θ. Choosing θ as the coordinate automatically respects the constraint, so the constraint force drops out.
A free particle has L = ½mẋ². Show momentum is conserved.
L does not depend on x (only on ẋ), so x is cyclic and ∂L/∂x = 0. The Euler–Lagrange equation gives d/dt(∂L/∂ẋ) = 0, i.e. d/dt(mẋ) = 0 — momentum p = mẋ is conserved. This is Noether's theorem applied to translational symmetry.
What does it mean for the Hamiltonian to equal T + V rather than something else?
Whenever the coordinate transformation to q doesn't depend explicitly on time and the potential doesn't depend on velocity, the Legendre transform H = Σpq̇ − L collapses exactly to T + V, the total mechanical energy. This isn't automatic in more exotic systems (e.g. a moving constraint), where H and total energy can differ.
Why are Hamilton's equations "first order" an advantage over the Euler–Lagrange second-order equation?
First-order equations in twice as many variables (q and p together) form a more symmetric, geometric structure — phase space — which is the natural setting for statistical mechanics (Chapter 20) and the direct bridge to quantum mechanics, where p and q become operators obeying the canonical commutation relation.
How the ideas connect
Every key idea in this chapter, branching from the core concept — use it to see the whole picture at a glance.
The process, step by step
Worked problems, step by step
Follow each solution line by line, then try to reproduce it on paper before moving on.
Example 1Write the Lagrangian of a simple pendulum of length l, mass m, angle theta.
- T = 0.5*m*l^2*theta_dot^2
- V = -m*g*l*cos(theta)
- L = T - V
Example 2Derive the pendulum equation of motion from that Lagrangian.
- dL/dtheta_dot = m*l^2*theta_dot, its time derivative is m*l^2*theta_ddot
- dL/dtheta = -m*g*l*sin(theta)
- Set d/dt(dL/dtheta_dot) - dL/dtheta = 0
Now you try
Work each one out first, then tap to reveal the worked answer.