4.10.12 · D2Advanced Topics (Elite Level)

Visual walkthrough — Calculus of variations — functionals, functional derivative

2,234 words10 min readBack to topic

We are going to answer one question: among all curves from point to point , which one makes a total "cost" as small as possible — and how do we recognise it?


Step 1 — What we are choosing: a whole curve, not a point

WHAT. In ordinary "find the minimum" problems you slide a single dot left and right until you reach the bottom of a valley. Here the thing we are allowed to change is an entire curve — a bendy wire pinned down at two nails, the left nail at and the right nail at .

WHY. Length, travel-time, energy — these all depend on the shape of the whole wire, not on one number. So the unknown itself is a shape.

PICTURE. Look at the figure. The horizontal axis is (position along the ground). The vertical axis is (height of the wire). The teal curve is one candidate wire. The two orange dots are the fixed endpoints — they never move.

Figure — Calculus of variations — functionals, functional derivative

Step 2 — How to "wiggle" a curve: the variation

WHAT. To test whether a curve is the best, we nudge it. We add a small bump scaled by a tiny knob :

WHY. In ordinary calculus you check a minimum by nudging a hair in every direction. A curve has infinitely many "directions" to be nudged — one for each shape of bump. So is our "which direction to wiggle," and is "how hard."

PICTURE. The teal curve is the candidate . The plum dashed curve is , the bump. The orange curve is the wiggled wire . Crucially the bump is flat at both nails — it must vanish there so the endpoints stay pinned.

Figure — Calculus of variations — functionals, functional derivative

Step 3 — Collapse the problem to one ordinary variable

WHAT. Freeze the bump shape and let only the dial move. Then the cost becomes an ordinary one-variable function:

WHY. This is the whole trick. We do not know how to do calculus on "space of all curves" directly, so we shine a 1-D beam through it: along this beam the cost is just a normal function , and we already know how to minimise those. If is truly the best curve, then moving off it in any direction can only raise the cost, so is the bottom of .

PICTURE. The parabola-like teal curve is . Its lowest point sits exactly at (the orange dot). The tangent line there is flat — slope zero.

Figure — Calculus of variations — functionals, functional derivative

This single equation, unpacked, is the Euler–Lagrange equation.


Step 4 — Differentiate under the integral (chain rule on the slices)

WHAT. Turn the dial and watch each slice-cost change. Differentiating with respect to :

WHY. Inside there are two slots that depend on : the height slot () and the slope slot (). The chain rule says: rate of change (sensitivity to height)(how fast height changes) (sensitivity to slope)(how fast slope changes). Turning the dial pushes height up by and slope up by — that is why rides with and rides with .

PICTURE. At one sample point, two arrows: the orange arrow shows how the slice cost responds to raising the height (, weighted by ); the teal arrow shows how it responds to tilting the slope (, weighted by ).

Figure — Calculus of variations — functionals, functional derivative

There is a snag: the two terms carry different wiggles — one has , the other has . We cannot yet factor out a common . Step 5 fixes this.


Step 5 — Integration by parts: move the derivative off the wiggle

WHAT. Rewrite the awkward term so it also carries a plain :

WHY. Integration by parts is the tool that swaps a derivative from one factor onto the other. That is exactly the surgery we need: it peels the prime off and drops it onto , leaving a bare we can factor out. We choose this tool precisely because is the object we want to isolate.

PICTURE. A "before / after" strip. Before: the derivative sits on (shown as a little prime tag on the plum bump). After: the derivative has hopped onto (the tag jumps across the teal factor), and a boundary term pops up at the two nails.

Figure — Calculus of variations — functionals, functional derivative

Step 6 — Now a single common factor

WHAT. Put the surviving pieces together:

WHY. After Step 5 both terms carry , so we factor it out. The bracket is the functional derivative — a "gradient" with one component per point . The equation says: no matter which wiggle we pick, this weighted sum is zero.

PICTURE. The bracket is drawn as a burnt-orange gradient field along : an arrow at every point telling the curve "push me down here, up there." The wiggle is the plum curve. Their product, integrated, is the shaded area — and it must total zero for every possible .

Figure — Calculus of variations — functionals, functional derivative

Step 7 — The Fundamental Lemma: from "for all " to "the bracket is zero"

WHAT. If for every smooth that vanishes at the ends, then everywhere.

WHY. Suppose the bracket were positive on some little stretch. We are free to choose any . So pick a bump that is a small positive lump sitting exactly on that stretch and zero elsewhere. Then is positive there and zero elsewhere, so the integral is strictly positive — contradicting "it equals zero for all ." The same argument kills any negative stretch. So can be nothing but zero.

PICTURE. A plum bump is parked on a spot where the bracket (burnt orange) is positive; the shaded product area is clearly positive — the contradiction, drawn.

Figure — Calculus of variations — functionals, functional derivative

Step 8 — Edge case: what if we don't nail the endpoints?

WHAT. Drop the requirement . Then the boundary term from Step 5 does not vanish. Setting now needs both the interior integral and the boundary term to vanish.

WHY. With a free end, wiggles are allowed to move the endpoint too, so we no longer get there. The only way can vanish for arbitrary end-wiggles is if itself is zero at the free end. These are the natural boundary conditions.

PICTURE. Left panel: pinned end — bump flat at the nail, boundary term . Right panel: free end — bump non-zero at the edge (orange), forcing .

Figure — Calculus of variations — functionals, functional derivative

The one-picture summary

Everything above, in a single flow: pin the wire → wiggle it → collapse to a 1-D dial → flat at the bottom → chain rule → integration by parts kills the boundary → factor out → Fundamental Lemma → Euler–Lagrange.

Figure — Calculus of variations — functionals, functional derivative

Whole curve y with fixed nails

Wiggle by eps times eta

Cost becomes Phi of eps

Minimum so Phi prime at 0 is zero

Chain rule under integral

Parts moves derivative off eta

Boundary term dies at nails

Factor out eta

Fundamental Lemma

Euler Lagrange equation

Recall Feynman: tell the whole walk to a 12-year-old

Imagine a bendy wire pinned to a board with two nails. You want the wire's shape that makes some total cost — its length, or the time a bead slides down it — as small as possible. How do you know when you've got the best shape? You give it a tiny wiggle anywhere in the middle (keeping the nails put) and check that the cost doesn't drop. If any wiggle could make it cheaper, you weren't at the best shape yet. Now, "a tiny wiggle of any shape, anywhere" sounds impossible to test — but there's a slick move. First you turn the wiggle into a single dial (turn the dial, the wire bulges more), so the cost is now an ordinary curve with a bottom, and the bottom is where the dial reads zero. Then you use two standard tricks: the chain rule (how does each little slice of cost react to raising the wire and to tilting it?), and integration by parts (a way to shove a derivative from the wiggle onto the cost, which also spits out a leftover at the nails — but that leftover is zero because the wiggle is zero at the nails). After that cleanup, the cost-change is one neat sum: (a certain quantity) times (your wiggle), added up along the wire. If that's zero for every wiggle you could ever draw, the only possibility is that "certain quantity" is zero at every single point. That quantity is the Euler–Lagrange expression, and setting it to zero is the rule that picks out the perfect curve.

See also: Lagrangian mechanics, Geodesics and differential geometry, Brachistochrone problem, Functional analysis, Constrained optimization & Lagrange multipliers.