Calculus of Variations
Ordinary calculus picks the best number; calculus of variations picks the best curve. The Euler-Lagrange equation turns that infinite search into a differential equation for the winner.
Why Does This Exist?
Shortest paths, fastest slides, least-action physics and minimum-energy splines all ask for the best function, not the best number. Brute-force search over curves is impossible, and discretizing first begs the question (the grid picks the answer). The calculus of variations converts the search into a differential equation: any minimizer must satisfy Euler-Lagrange, so candidates come from ODE theory instead of guessing.
This page derives that equation and proves the straight line wins. Finite-dimensional constraints are constrained optimisation and duality; optimality certificates are KKT conditions.
The one idea you need first
A functional scores whole curves with a running cost . A variation wiggles the curve ( zero at endpoints). Optimality demands the first wiggle change nothing: .
Think of It Like This
The fastest sled run down a hill
A sled hill offers infinite routes from top to bottom. Timing each is hopeless, but physics says the winner must satisfy a local balance at every point: steepen where speed pays, flatten where it does not. That balance is Euler-Lagrange, and it narrows infinity to a few candidate tracks.
The straight line is not always the winner (the brachistochrone curves to bank speed early). Where it stops: the equation finds stationarity, not victory. Maxima, saddles and unstable extremals satisfy it too; second-variation or direct comparison picks the true minimizer.
How It Actually Works
Wiggle by and expand to first order; integration by parts moves derivatives off :
In plain words: prices position and slope, is an arbitrary wiggle vanishing at the ends, and since the integral must vanish for every wiggle, the bracket does too. That bracket is the Euler-Lagrange equation:
For length : , so , giving and : straight lines.
Worked example
From to : straight , length . Rival parabola (same endpoints: and ✓): length . Split at midpoint Simpson with : values , , : length . True value .
Straight beats parabola by : Euler-Lagrange's prediction confirmed by direct measurement.
Code
Quadrature lengths confirm the straight line undercuts the parabola.
import numpy as np
def length(ys: np.ndarray, dx: float) -> float: slopes = np.diff(ys) / dx # segment slopes along the curve return float(np.sqrt(1 + slopes**2).sum() * dx) # sum of segment lengths
x = np.linspace(0.0, 2.0, 2001)print(round(length(x / 2, x[1] - x[0]), 3)) # -> 2.236print(round(length(x**2 / 4, x[1] - x[0]), 3)) # -> 2.295 approxversus about : the minimizer wins on the nose.
Watch Out For
Calling every extremal a minimizer
Symptom: Euler-Lagrange solved, solution shipped, yet a rival curve scores lower (saddle or maximizer). Fix: compare values directly or check Legendre's strengthened second-variation condition; stationarity alone never certifies minimality.
Varying with endpoints nailed down wrong
Symptom: boundary terms dropped when endpoints are actually free, losing the transversality condition and admitting false extremals. Fix: keep the boundary term unless variations truly vanish there.
The Quick Version
- Functionals score curves; vanishing first variation gives the Euler-Lagrange equation.
- Length Lagrangians yield : minimizers are straight lines.
- to : straight measures , parabola about .
- Extremals can be maxima or saddles; direct comparison certifies the winner.
- Free endpoints need transversality terms that fixed-endpoint problems drop.