When finding the absolute maximum or minimum of f on a closed region D, we saw in Local Extrema that we must check both the interior critical points and the boundary. Lagrange multipliers give a systematic method for handling boundaries defined by a single equation.
Many practical optimization problems have this structure:
Maximize or minimize f(x,y,z) subject to the constraint g(x,y,z)=k.
The constraint g=k defines a curve in R2 or a surface in R3, and we restrict attention to points on it.
2. Constraint curves and surfaces
A constraint g(x,y)=k in the plane defines a curve — for example, x2+y2=1 is the unit circle, and (x−2)2+y2=1 is a circle of radius 1 centered at (2,0).
A constraint g(x,y,z)=k in space defines a surface — for example, x2+y2+z2=4 is a sphere of radius 2.
We want to find the largest and smallest values that f achieves as the point (x,y) (or (x,y,z)) moves along the constraint.
3. Motivating example: minimize f=x2+y2 on a circle
Geometrically, we are asking: what is the closest and farthest point on the circle (x−2)2+y2=1 from the origin?
Blue paraboloid = z = x²+y². Red curve = constraint (x−2)²+y²=1 on the surface. The constraint curve achieves its minimum value f=1 at (1,0) and maximum f=9 at (3,0).
The constraint curve sits on the paraboloid z=x2+y2. The minimum of f on the constraint is 1 at (1,0) and the maximum is 9 at (3,0).
4. The method of Lagrange multipliers
Theorem. If f has a maximum or minimum on the constraint g(x,y)=k at a point (x0,y0), and if ∇g(x0,y0)=0, then there exists a scalar λ (the Lagrange multiplier) such that
∇f(x0,y0)=λ∇g(x0,y0).
To find all candidates, solve the system:
{∇f=λ∇gg(x,y)=k.
For three variables the same system applies with (x0,y0,z0) and g(x,y,z)=k.
5. Geometric interpretation
Why must ∇f=λ∇g at an extremum?
The level curves of f(x,y) form a family of concentric curves. The constraint is a single curve g=k. As we slide along the constraint, the value of f changes — unless the constraint is tangent to a level curve of f at that point.
At a tangent point the two curves share the same tangent line, so their normal vectors (the gradients) are parallel: ∇f=λ∇g for some scalar λ.
Level curves of f=x²+y² tangent to constraint (x−2)²+y²=1 at the extrema
The circles x2+y2=1, 4, 9 are level curves of f. The red circle is the constraint. At the two extrema — (1,0) and (3,0) — the constraint is tangent to a level curve of f, confirming that the gradients are parallel.
6. Lagrangian formulation
An equivalent reformulation defines the Lagrangian:
L(x,y,λ)=f(x,y)−λ(g(x,y)−k).
Setting ∇L=0 gives:
∂x∂L=fx−λgx=0,∂y∂L=fy−λgy=0,∂λ∂L=−(g−k)=0.
These are exactly ∇f=λ∇g plus the constraint g=k. The Lagrangian packages all conditions into one system.
7. Example: closest and farthest points on a sphere
Problem. Find the points on x2+y2+z2=4 that are closest to and farthest from the point (3,1,−1).
We minimize and maximize d2=(x−3)2+(y−1)2+(z+1)2 (minimizing the squared distance avoids a square root) subject to g(x,y,z)=x2+y2+z2=4.
Blue = sphere x²+y²+z²=4. The line through the origin in direction (3,1,−1) intersects the sphere at the closest and farthest points from the external point (3,1,−1).
Solution. Set f=(x−3)2+(y−1)2+(z+1)2. Then
∇f=⟨2(x−3),2(y−1),2(z+1)⟩,∇g=⟨2x,2y,2z⟩.
The Lagrange condition ∇f=λ∇g gives three equations:
x−3=λx,y−1=λy,z+1=λz.
Rewrite as x(1−λ)=3, y(1−λ)=1, z(1−λ)=−1.
Assuming λ=1, divide to get the ratios x:y:z=3:1:−1. Write (x,y,z)=k(3,1,−1) for some scalar k.