Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.The highest point on a trail
You must stay on a winding hiking trail. Where on the trail are you highest? Not at the mountain’s peak, which may be off the trail. At the best spot, the trail just touches a contour line without crossing it. If the trail crossed the contour, you could keep walking uphill along the trail.
That touching condition is the idea behind Lagrange multipliers.
Engineers rarely optimize freely. A rocket must reach orbit using a fixed amount of fuel, a robot arm must keep its hand on a door handle, and a battery can only supply so much power. Lagrange multipliers solve these “best under a rule” problems, and they also say how much better things would be if the rule were loosened.
- 1. At the trail's highest point, the trail…
- 2. Two numbers add to 10. To make their product as big as possible, choose…
- 3. With 20 m of fence, the biggest rectangle has side…
Level 1: Beginner
★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.The method
To optimize subject to , solve
That’s three equations in . Equivalently, find the critical points of the Lagrangian .
Example. Maximize subject to . Then , so , and the constraint gives . The maximum is , with .
Fence. Maximize subject to . This gives a square of side .
- 1. max xy subject to x + y = 10?
- 2. The Lagrange condition is…
- 3. The best rectangle with perimeter 40 has area…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.Why the gradients must be parallel
is normal to the constraint curve (A3.2-3). If had a component along the curve, moving along the curve would change , so the point couldn’t be optimal. So must point along . Equivalently, the level curve of is tangent to the constraint.
What λ means: the shadow price
If the constraint level changes from to , the best value changes by about :
For with : , so . In economics, is the price you would pay for one more unit of the resource.
More examples
| Problem | Lagrange solution |
|---|---|
| closest point to the origin on the plane | , distance |
| min-norm solution of | , the pseudo-inverse (A2.3-7) |
| extremize a quadratic form on the sphere | : eigenvectors (A2.4-2) |
| max entropy with known mean | , an exponential family |
Several constraints: , with one multiplier per constraint.
- 1. Distance from the origin to x + 2y + 2z = 6?
- 2. Extremizing xᵀAx on the unit sphere gives…
- 3. λ equals…
Level 3: Advanced
★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.The theorem and its fine print
If is a local extremum of on , and are , and , then for some .
Proof. Since , the implicit function theorem (A3.2-4) makes a smooth curve (or surface) near . For any curve in it through , has an extremum at , so . So is orthogonal to every tangent direction, as is . In codimension one, this forces them to be parallel. ∎
The condition (a constraint qualification) matters. For on , the minimum is at the cusp , where and no exists.
Second-order check and inequality constraints
The Lagrange condition finds candidates. To tell a max from a min, look at the Hessian of restricted to the tangent space of the constraint (the “bordered Hessian”). For inequality constraints , the KKT conditions add and complementary slackness . An inactive constraint gets . This is the foundation of convex optimization and duality (A6).
Exercise 3.1: Show that λ = df*/dc (the envelope theorem)
, so . Differentiating gives . Hence .
- 1. The Lagrange theorem needs…
- 2. An inactive inequality constraint has multiplier…
- 3. With 3 equality constraints, how many multipliers?
Level 4: Expert
★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.In mechanics, the multiplier is the constraint force
A pendulum bob is a particle constrained to . Lagrange’s mechanics (1788) writes . Differentiating the constraint twice gives at every instant, and is the rod’s tension. Physics engines simulate joints, contacts and closed kinematic chains exactly this way, solving for multipliers (constraint impulses) every timestep (Featherstone, 2008; Todorov, Erez and Tassa, 2012).
Multipliers in ML and robotics
- Support vector machines. The dual of the max-margin problem has one multiplier per training point. Points with are the support vectors (Cortes and Vapnik, 1995; D5).
- Maximum entropy. The least-committal distribution matching given moments is an exponential family whose parameters are the Lagrange multipliers (Jaynes, 1957; Practice Code 5). This underlies logistic regression, softmax, and maximum-entropy inverse RL (Ziebart et al., 2008).
- Safe reinforcement learning. Constrained MDPs maximize reward subject to expected cost . Lagrangian methods learn alongside the policy, raising the “price” of unsafe behaviour until the constraint holds (Altman, 1999; Tessler, Mankowitz and Mannor, 2019; Stooke, Achiam and Abbeel, 2020).
- Trajectory optimization. Dynamics and contact constraints are enforced with multipliers (direct collocation, augmented Lagrangian solvers like ALTRO). The multipliers at the solution are the contact forces and their sensitivities.
References
- J.-L. Lagrange (1788). Mécanique analytique.
- E. T. Jaynes (1957). “Information theory and statistical mechanics.” Physical Review, 106(4).
- H. Kuhn, A. Tucker (1951). “Nonlinear programming.” Proc. 2nd Berkeley Symposium. (KKT conditions; also W. Karush, 1939.)
- C. Cortes, V. Vapnik (1995). “Support-vector networks.” Machine Learning, 20.
- E. Altman (1999). Constrained Markov Decision Processes. Chapman & Hall.
- B. Ziebart, A. Maas, J. A. Bagnell, A. Dey (2008). “Maximum entropy inverse reinforcement learning.” AAAI.
- R. Featherstone (2008). Rigid Body Dynamics Algorithms. Springer.
- C. Tessler, D. Mankowitz, S. Mannor (2019). “Reward constrained policy optimization.” ICLR.
- S. Boyd, L. Vandenberghe (2004). Convex Optimization. Cambridge University Press. Chapter 5.