Calculus of Variations and the Euler-Lagrange Equation
A branch of calculus for finding the best whole function or path — not just the best single number — by turning 'which function minimizes this quantity' into a differential equation that any optimal function must satisfy.
Prerequisites: The Fundamental Theorem of Calculus
Ordinary calculus finds the single number that minimizes a function — set the derivative to zero, solve. But some problems ask for the best entire function: what consumption path over a lifetime maximizes total satisfaction, what trading trajectory minimizes market impact while liquidating a position, what shape minimizes travel time. There the unknown isn't a number, it's a whole curve, and the tool for finding it is the calculus of variations — its central result, the Euler-Lagrange equation, converts "which function is best" into an ordinary differential equation that any optimal function must obey.
An analogy: rippling a string to find its rest shape
Imagine a stretched elastic string under tension, free to sag under gravity between two fixed endpoints. Physically, the string settles into whatever shape minimizes its total potential energy. You could, in principle, compare every conceivable curve connecting the two endpoints and check which has lowest energy — an impossible search over infinitely many candidate shapes. Instead, physics says: nudge the true resting shape by any tiny perturbation, and the energy shouldn't change to first order, because it's already sitting at a minimum. Turning that "no first-order change under any nudge" condition into equations gives you a differential equation the true shape must satisfy, pinning down the winning curve without ever comparing it to its infinitely many rivals directly.
The equation, one symbol at a time
Consider minimizing a quantity expressed as an integral over a candidate function between fixed endpoints:
where , called the Lagrangian, is some known expression combining , the function's value , and its slope at each point — is a single number (the "cost" or "energy") that depends on the entire shape of , not just one point. The function that minimizes must satisfy the Euler-Lagrange equation:
In plain English: at the optimal function, the direct sensitivity of the cost to nudging up or down at a point must exactly balance the rate of change, along the curve, of the cost's sensitivity to the slope at that point — a local balance condition that, applied at every , pins down the whole optimal curve as the solution to a differential equation.
Worked example 1: the shortest path is a straight line
Minimize arc length between two points, (this is what "minimize length" looks like as an integral). Since doesn't depend on directly, , so the Euler-Lagrange equation reduces to , meaning is constant along the optimal path. A fraction with this form staying constant forces itself to be constant — the slope never changes. A curve with constant slope is a straight line. The calculus of variations recovers, from pure symbol manipulation, the geometrically obvious fact that the shortest path between two points is a straight line — reassuring on a simple case, and the same machinery generalizes to problems with no obvious answer.
Worked example 2: a minimal-impact trading trajectory
Suppose an idealized cost of trading at rate (shares per unit time) is — a standard simplification where trading impact cost grows with the square of trading speed, penalizing fast trading disproportionately. Since doesn't depend on directly here either, the same logic applies: must be constant, forcing constant — the cost-minimizing strategy trades at a constant rate throughout the period, never speeding up or slowing down. This is the textbook justification for a simple time-weighted-average-price (TWAP) execution schedule under a quadratic impact assumption: the calculus of variations shows constant-rate trading isn't just a convenient default, it's the actual minimizer of total impact cost under that cost model.
What this means in practice
Calculus of variations underlies optimal execution models (from the simple constant-rate result above to more elaborate models like Almgren-Chriss, which balance impact cost against price-risk over time), consumption-investment problems in lifetime portfolio theory, and interest-rate curve fitting where the fitted curve is chosen to minimize a smoothness-penalized fit to market data. Wherever a problem asks for a best function of time rather than a best number, this machinery is the standard route to a solvable equation.
The Euler-Lagrange equation, , is the condition any function that minimizes an integral cost must satisfy — it converts "find the best function" into an ordinary differential equation for that function.
Solving the Euler-Lagrange equation gives a function where the cost is stationary — unchanged to first order under small nudges — which is necessary for a minimum but not automatically sufficient; the resulting curve could in principle be a maximum or a saddle in function-space. In practice, for the well-behaved convex cost functions common in finance (like the quadratic impact cost above), the stationary solution is indeed the minimizer, but that convexity should be checked, not assumed, before trusting the result as optimal rather than merely stationary.
Practice in interviews
Further reading
- Gelfand & Fomin, Calculus of Variations
- Kirk, Optimal Control Theory: An Introduction