TL;DR
Ordinary calculus finds the number that makes a function smallest. Calculus of variations finds the whole function that makes a total quantity, called a functional, smallest. The key test is that if is optimal, then nudging it slightly in any direction must not change the total to first order. Applying that test gives a differential equation, the Euler–Lagrange equation, that the best curve must satisfy.
Where you'll see it: in finding the shortest path between two points on a curved surface, in classical mechanics where a path minimises the action, and in optimal control, where a controller is chosen to minimise a cost over time.
Intuition
Suppose you want the fastest route for a ball to roll from a high point to a lower one. The answer is not a single number. It is a whole shape, a curve that falls steeply at first and then flattens. You need to compare entire candidate curves, and the quantity you compare is an integral: the total time along the curve.
Calculus of variations is the standard tool for that. Its objects are curves, and the thing being optimised is a total value that depends on the whole curve. Such a total is called a functional, because it takes a function as input and returns a number.
The figure below shows three candidate curves between the same two endpoints, and . Each one gives a different total, and the variational problem is to find the one that gives the smallest. Its shape is not obvious in advance, which is why the method is needed.
- y = x
- y = x^2
- y = sinh(x)/sinh(1)
The idea behind the method is simple. At a minimum of an ordinary function, the slope is zero, so a tiny step in any direction changes the value only to second order. The same must hold for a curve. If is the best curve, then for any small wiggle added to it, the total must not change to first order. That single requirement is enough to pin down the answer.
The math
The functional
Let be a function on an interval with fixed endpoints and . Let be a known function of three variables, and define the functional
Here is the derivative of with respect to , and the square brackets around are the usual notation for "a functional of the function ". The task is to find the that makes as small as possible among all curves that satisfy the endpoint conditions.
The first variation
Pick any smooth function with . This is a wiggle that does not move the endpoints. For a small number , define the perturbed curve . It still satisfies the endpoint conditions.
Define . If is optimal, then has a minimum at , so . Compute that derivative. Differentiating under the integral sign, and using the chain rule from Partial Derivative for the dependence of on its second and third arguments, gives
Here and are the partial derivatives of with respect to its second and third arguments. The condition must hold for every admissible .
Removing the derivative of the wiggle
The second term contains , which is inconvenient because we want a condition on itself. Integrate it by parts, which is exactly the move in Integration by Parts. Take and , so :
The boundary term vanishes because . Substitute back and collect:
The Euler–Lagrange equation
Since is arbitrary, the only way this integral vanishes for every is that the bracket is zero everywhere on . That gives the Euler–Lagrange equation:
Any extremal curve, a candidate minimum or maximum, must satisfy it. It is a second-order ordinary differential equation for in general, so its solutions form a family, and the endpoint conditions select one member.
The equation is necessary, not sufficient. A solution might be a maximum, or a saddle. When is convex in , which holds for the examples here, any solution is the global minimum.
Worked examples
The arc length of a curve on is . Here does not depend on or .
- The partial derivative with respect to is .
- The partial derivative with respect to is .
- The Euler–Lagrange equation becomes .
- So is a constant, call it .
- Solving for gives , which is constant. So for a constant .
- Integrating gives , a straight line.
The equation recovers the obvious answer: the shortest path between two points in a flat plane is a straight line. The method works without knowing that answer in advance.
Minimise subject to and .
- Here , so and .
- The Euler–Lagrange equation is , which simplifies to .
- The general solution is .
- The condition gives . The condition gives , so .
- Numerically, , so . At , , so .
- For the minimal value, use , which holds because . Then .
- Since , .
Compare this to the straight line , which satisfies both endpoint conditions. Its value is , which is larger than . The curve that bends below the line does better, as the Plot above shows.
Tradeoffs and failure modes
Calculus of variations is the right tool when the unknown is a function and the objective is an integral. For other problems, other tools are better.
| Situation | Problem | Better choice |
|---|---|---|
| The curve is smooth and is simple | Solving the Euler–Lagrange ODE may be hard, but tractable | Solve the ODE analytically, as in example 2 |
| The ODE has no closed form | Analytic solution is out of reach | Parameterise with a few unknowns and minimise numerically (the Ritz method) |
| There is a constraint such as a fixed length | The Euler–Lagrange equation alone ignores it | Add a multiplier term; the constrained problem gives an extended Euler–Lagrange equation |
| An endpoint is free | No endpoint condition is fixed | Use the natural boundary condition at the free end |
| The problem is a control problem with dynamics | The state evolves by an ODE and the input is free | Use optimal control and Pontryagin's principle (see Optimal Control) |
| The curve is not smooth | Euler–Lagrange assumes differentiability | Use a weak or relaxed formulation |
A practical warning: finding a solution of the Euler–Lagrange equation does not prove it is the minimum. In a gradient-based numerical search, the same caveat appears as a local minimum. Check convexity or the second variation before trusting a candidate.
History
Johann Bernoulli posed the brachistochrone problem, the curve of fastest descent between two points under gravity, in 1696 and challenged the mathematicians of Europe to solve it. Newton, Leibniz, Jakob Bernoulli and others produced solutions, and the cycloid turned out to be the answer. These solutions were ad hoc, each using its own geometry, and the problem stimulated the search for a general method.
In the 1740s Leonhard Euler systematised the approach and gave the general condition that now carries his name. The variation method, using the small perturbation and the first-variation argument, is usually credited to Joseph-Louis Lagrange in the 1750s, who worked out the notation that is still used. The equation became central to classical mechanics: Lagrange's formulation of mechanics expresses the equations of motion as the stationarity of an action functional.
It caught on because it turned many separate problems into one procedure, and because the same condition describes both the shortest path in geometry and the trajectory of a physical system.
Check yourself
QuestionWhy must the variation vanish at the endpoints and ?Show answer
The endpoint values of the optimal curve are fixed by the problem, and . The perturbed curve must satisfy the same conditions to be an admissible competitor. If , the perturbation would move the fixed endpoint, and the comparison would not be between valid candidates. The vanishing also kills the boundary term produced by the integration by parts.
QuestionFor the functional with and no derivative term, write down the Euler–Lagrange equation and solve it.Show answer
The equation is . Here and , so the equation is , giving for all . With endpoint conditions , the minimum is , attained by the zero function. This is an edge case: the equation has no derivative term, so the solution is an algebraic constraint rather than a differential equation.
QuestionIn example 1, the shortest path came out to be a straight line without any endpoint-specific computation. Why does the method not need the endpoints to find the shape, and where do they enter?Show answer
The Euler–Lagrange equation is an ODE, and its general solution for the shortest-path problem is a family of straight lines . The shape (straightness) is fixed by the structure of . The endpoints enter only when you fix the two constants and using and . So the endpoints choose which line, but not the fact that it is a line.
QuestionA chemical plant needs to choose a temperature profile over an hour to minimise a cost integral. Why is the Euler–Lagrange equation alone not enough, and what extra structure does the problem need?Show answer
The cost depends on and possibly its rate of change, and it is an integral, so calculus of variations applies in principle. But a real plant has dynamics: the state evolves according to an ODE driven by the control, and the temperature is often bounded. The Euler–Lagrange equation ignores both. The problem needs optimal control, with a Hamiltonian and Pontryagin's principle, which generalises the first-variation argument to controls with constraints. The basic variational idea remains the foundation.