The Spacetime Metric
Level 3 · Undergraduate coreFirst- and second-year universityAbout 15 hours

Lagrangian and Hamiltonian mechanics

Replace force-by-force bookkeeping with action, generalized coordinates, symmetry, and phase space.

Derive Euler–Lagrange and Hamilton equations, connect continuous symmetries to conserved quantities, and prepare the formal bridge into fields and quantum mechanics.

Established foundations

Before you begin

  • Calculus, vectors, and differential equations
  • Level 2 mechanics
  • Partial derivatives

By the end, you can

  • Construct L=T−V in generalized coordinates.
  • Derive and solve Euler–Lagrange equations.
  • Identify cyclic coordinates and conserved momenta.
  • Translate between Lagrangian, Hamiltonian, and phase-space descriptions.

Interactive model

Explore before calculating

A moving degree of freedom represented together with a surrounding field response.
Variational mechanics isolates the degrees of freedom and action before assigning a microscopic interpretation to inertia.

Live laboratory

Stationary-action path atelier

Compare fixed-endpoint trial paths q(t)=qclassical(t)+α sin(πt/T). The Euler–Lagrange path sits at α=0, where the first-order action change vanishes.

α=−2α=0α=2

Oscillator frequency: 1.000

ωT: 1.000

Classical-path action: 3.2105e-1

Trial-path action: 3.2105e-1

ΔS: 0.0000e+0

Maximum path offset: 0.00

Positive and negative small α produce the same leading quadratic action change in this trial family, while the linear change vanishes at α=0. That is the numerical signature of stationarity.

The parameter ranges keep ωT below π, so the classical path is a local minimum within this sine-variation family. Stationary action is not universally a minimum, and this one-coordinate oscillator does not replace a general variational derivation or constrained Hamiltonian analysis.

Level 3 · Undergraduate core teaching kit

Record the investigation. Teach the reasoning.

A learner-facing lab record and a course-specific instructor guide turn the live model into a repeatable classroom investigation.

Learner record

Fixed-endpoint stationary-action test

How does the classical oscillator path respond to positive and negative variations that share its endpoints?

Download learner record

Instructor guide

Teach for evidence, not button pushing

Learners interpret stationary action as cancellation of first-order fixed-endpoint variations rather than a force-free or universally minimum path.

Download instructor guide
Open the complete print-friendly teaching kit →

Lesson 1 of 3

Action and Euler–Lagrange equations

How can one stationary-action rule encode Newton's equations?

The action S=∫Ldt assigns a number to an entire path. The physical path makes the first-order change in S vanish under fixed-endpoint variations.

For ordinary particles L=T−V. The Euler–Lagrange equation follows by integration by parts and applies equally well in non-Cartesian coordinates.

actionvariationLagrangiangeneralized coordinate

Worked example

For L=½m q̇²−V(q), derive motion.

  1. 1. ∂L/∂q̇=mq̇.
  2. 2. d/dt gives mq̈.
  3. 3. ∂L/∂q=−dV/dq.

mq̈=−dV/dq, Newton's law for a conservative force.

Try it

Competing-path action

Materials: Spreadsheet with trial paths between fixed endpoints.

  1. 1. Choose a harmonic-oscillator Lagrangian.
  2. 2. Evaluate discrete action for several paths.
  3. 3. Perturb the near-solution path.
  4. 4. Compare first-order action changes.

Notice: Stationary does not always mean minimum, but nearby first-order changes cancel on the physical path.

Check your understanding: Why must endpoint variations vanish in the standard derivation?

Answer: So the boundary term from integration by parts disappears.

The compared paths share initial and final configurations.

Lesson 2 of 3

Symmetry and conservation

Why does ignoring an absolute coordinate produce a conserved momentum?

If L has no explicit dependence on a coordinate, that coordinate is cyclic and its conjugate momentum is conserved.

Noether's theorem generalizes this: continuous symmetries of the action correspond to conserved currents or charges.

cyclic coordinateconjugate momentumNoether theoremsymmetry

Worked example

L=½m(ẋ²+ẏ²)−V(y). What is conserved?

  1. 1. L contains no x.
  2. 2. Euler–Lagrange gives d(∂L/∂ẋ)/dt=0.
  3. 3. ∂L/∂ẋ=mẋ.

x-momentum is conserved because translations in x leave the action unchanged.

Try it

Symmetry audit

Materials: Several simple Lagrangians.

  1. 1. Mark absent coordinates.
  2. 2. Compute conjugate momenta.
  3. 3. Identify time-translation invariance.
  4. 4. Predict conserved quantities before solving.

Notice: Conservation becomes a structural consequence, not a separate memorized rule.

Check your understanding: What symmetry is associated with energy conservation?

Answer: Continuous time-translation symmetry.

When the Lagrangian has no explicit time dependence, the Hamiltonian-like energy is conserved under standard conditions.

Lesson 3 of 3

Hamiltonians and phase space

What changes when positions and momenta become independent state coordinates?

The Hamiltonian H=Σpᵢq̇ᵢ−L is a Legendre transform. Hamilton's first-order equations evolve coordinates and momenta together.

Phase space reveals conserved surfaces, stability, and canonical structure that later becomes central to statistical and quantum mechanics.

Hamiltonianphase spaceLegendre transformPoisson bracket

Worked example

Find H for L=½mq̇²−½kq².

  1. 1. p=∂L/∂q̇=mq̇.
  2. 2. Write q̇=p/m.
  3. 3. Compute H=pq̇−L.

H=p²/(2m)+½kq², the total oscillator energy.

Try it

Phase portrait

Materials: Notebook or graphing tool.

  1. 1. Integrate oscillator q and p.
  2. 2. Plot p versus q.
  3. 3. Change initial energy.
  4. 4. Relate closed curves to conservation.

Notice: Each conserved-energy trajectory forms an ellipse in oscillator phase space.

Check your understanding: How many first-order Hamilton equations replace one second-order equation per coordinate?

Answer: Two: one for q̇ and one for ṗ.

Phase-space state contains both coordinate and conjugate momentum.

Formula-to-meaning deck

Read the equation in ordinary language.

S=∫L(q,q̇,t)dt

Action assigns a scalar to a complete path.

d/dt(∂L/∂q̇ᵢ)−∂L/∂qᵢ=0

Euler–Lagrange equations determine stationary-action motion.

q̇ᵢ=∂H/∂pᵢ; ṗᵢ=−∂H/∂qᵢ

Hamilton's equations generate phase-space flow.

Independent practice

Problem set

Work each problem before opening its hint and solution.

  1. 1. Derive the pendulum equation from L=½mℓ²θ̇²−mgℓ(1−cosθ).

    Reveal hint

    Compute derivatives with respect to θ̇ and θ.

    Reveal solution

    θ̈+(g/ℓ)sinθ=0.

  2. 2. For a free particle in polar coordinates, identify the cyclic coordinate.

    Reveal hint

    L=½m(ṙ²+r²φ̇²).

    Reveal solution

    φ is cyclic, so pφ=mr²φ̇ is conserved angular momentum.

  3. 3. Write Hamilton's equations for H=p²/(2m)+V(q).

    Reveal hint

    Differentiate H once with respect to each phase variable.

    Reveal solution

    q̇=p/m and ṗ=−dV/dq.

Derivation studio

Build the result, line by line.

Keep the assumptions visible so the mathematics remains auditable.

Starting point

Euler–Lagrange equation

δS=δ∫L(q,q̇,t)dt=0

  1. 1. Expand δL=(∂L/∂q)δq+(∂L/∂q̇)δq̇.
  2. 2. Use δq̇=d(δq)/dt.
  3. 3. Integrate the second term by parts.
  4. 4. Drop fixed-endpoint boundary terms and require arbitrary δq coefficient to vanish.

d/dt(∂L/∂q̇)−∂L/∂q=0

A global stationary-path condition becomes a local differential equation.

Starting point

Hamilton equations from the Legendre transform

H(q,p,t)=pq̇−L with p=∂L/∂q̇

  1. 1. Take total differential dH.
  2. 2. Substitute dL terms.
  3. 3. Cancel p d q̇.
  4. 4. Match coefficients of dq, dp, and dt.

q̇=∂H/∂p and ṗ=−∂H/∂q

Dynamics becomes canonical flow on phase space.

Computational notebook

Turn the model into an experiment.

Nonlinear pendulum phase space

Where does the small-angle approximation stop preserving the true period and phase portrait?

Inputs

  • ℓ, g, initial angle and angular speed
  • exact sinθ and linear θ models

Algorithm

  1. 1. Integrate both equations.
  2. 2. Measure period versus amplitude.
  3. 3. Plot phase portraits.
  4. 4. Quantify relative period error.

Evidence to produce

  • Period-amplitude curve
  • Exact and approximate phase portraits
  • A justified approximation threshold

Continue into the evidence