← Back to calculus 3

Lagrange Multipliers

Lagrange Multipliers

1. Motivation: the boundary problem

When finding the absolute maximum or minimum of ff on a closed region DD, 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)f(x,y,z) subject to the constraint g(x,y,z)=kg(x,y,z) = k.

The constraint g=kg = k defines a curve in R2\mathbb{R}^2 or a surface in R3\mathbb{R}^3, and we restrict attention to points on it.


2. Constraint curves and surfaces

A constraint g(x,y)=kg(x,y) = k in the plane defines a curve — for example, x2+y2=1x^2 + y^2 = 1 is the unit circle, and (x2)2+y2=1(x-2)^2 + y^2 = 1 is a circle of radius 11 centered at (2,0)(2,0).

A constraint g(x,y,z)=kg(x,y,z) = k in space defines a surface — for example, x2+y2+z2=4x^2+y^2+z^2 = 4 is a sphere of radius 22.

We want to find the largest and smallest values that ff achieves as the point (x,y)(x,y) (or (x,y,z)(x,y,z)) moves along the constraint.


3. Motivating example: minimize f=x2+y2f = x^2 + y^2 on a circle

Consider

minimize/maximizef(x,y)=x2+y2subject to(x2)2+y2=1.\text{minimize/maximize} \quad f(x,y) = x^2 + y^2 \quad \text{subject to} \quad (x-2)^2 + y^2 = 1.

Geometrically, we are asking: what is the closest and farthest point on the circle (x2)2+y2=1(x-2)^2 + y^2 = 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+y2z = x^2 + y^2. The minimum of ff on the constraint is 11 at (1,0)(1,0) and the maximum is 99 at (3,0)(3,0).


4. The method of Lagrange multipliers

Theorem. If ff has a maximum or minimum on the constraint g(x,y)=kg(x,y) = k at a point (x0,y0)(x_0, y_0), and if g(x0,y0)0\nabla g(x_0,y_0) \neq \mathbf{0}, then there exists a scalar λ\lambda (the Lagrange multiplier) such that

f(x0,y0)=λg(x0,y0).\boxed{\nabla f(x_0,y_0) = \lambda\, \nabla g(x_0,y_0).}

To find all candidates, solve the system:

{f=λgg(x,y)=k.\begin{cases} \nabla f = \lambda\, \nabla g \\ g(x,y) = k. \end{cases}

For three variables the same system applies with (x0,y0,z0)(x_0,y_0,z_0) and g(x,y,z)=kg(x,y,z) = k.


5. Geometric interpretation

Why must f=λg\nabla f = \lambda\, \nabla g at an extremum?

The level curves of f(x,y)f(x,y) form a family of concentric curves. The constraint is a single curve g=kg = k. As we slide along the constraint, the value of ff changes — unless the constraint is tangent to a level curve of ff 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\nabla f = \lambda\, \nabla g for some scalar λ\lambda.

Level curves of f=x²+y² tangent to constraint (x−2)²+y²=1 at the extrema

The circles x2+y2=1x^2+y^2=1, 44, 99 are level curves of ff. The red circle is the constraint. At the two extrema — (1,0)(1,0) and (3,0)(3,0) — the constraint is tangent to a level curve of ff, 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).\mathcal{L}(x,y,\lambda) = f(x,y) - \lambda\bigl(g(x,y) - k\bigr).

Setting L=0\nabla \mathcal{L} = \mathbf{0} gives:

Lx=fxλgx=0,\frac{\partial \mathcal{L}}{\partial x} = f_x - \lambda g_x = 0, Ly=fyλgy=0,\frac{\partial \mathcal{L}}{\partial y} = f_y - \lambda g_y = 0, Lλ=(gk)=0.\frac{\partial \mathcal{L}}{\partial \lambda} = -(g - k) = 0.

These are exactly f=λg\nabla f = \lambda \nabla g plus the constraint g=kg = 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=4x^2 + y^2 + z^2 = 4 that are closest to and farthest from the point (3,1,1)(3, 1, -1).

We minimize and maximize d2=(x3)2+(y1)2+(z+1)2d^2 = (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=4g(x,y,z) = x^2+y^2+z^2 = 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=(x3)2+(y1)2+(z+1)2f = (x-3)^2 + (y-1)^2 + (z+1)^2. Then

f=2(x3),  2(y1),  2(z+1),g=2x,  2y,  2z.\nabla f = \langle 2(x-3),\; 2(y-1),\; 2(z+1) \rangle, \qquad \nabla g = \langle 2x,\; 2y,\; 2z \rangle.

The Lagrange condition f=λg\nabla f = \lambda \nabla g gives three equations:

x3=λx,y1=λy,z+1=λz.x - 3 = \lambda x, \qquad y - 1 = \lambda y, \qquad z + 1 = \lambda z.

Rewrite as x(1λ)=3x(1-\lambda) = 3,   y(1λ)=1\; y(1-\lambda) = 1,   z(1λ)=1\; z(1-\lambda) = -1.

Assuming λ1\lambda \neq 1, divide to get the ratios x:y:z=3:1:1x : y : z = 3 : 1 : {-1}. Write (x,y,z)=k(3,1,1)(x,y,z) = k(3,1,-1) for some scalar kk.

Substitute into the constraint:

k2(9+1+1)=4    k2=411    k=±211.k^2(9 + 1 + 1) = 4 \implies k^2 = \frac{4}{11} \implies k = \pm\frac{2}{\sqrt{11}}.

This gives two candidate points:

P+=211(3,1,1)=(611,  211,  211)(1.81,0.60,0.60),P_+ = \frac{2}{\sqrt{11}}(3,1,-1) = \left(\frac{6}{\sqrt{11}},\; \frac{2}{\sqrt{11}},\; -\frac{2}{\sqrt{11}}\right) \approx (1.81,\, 0.60,\, -0.60),

P=211(3,1,1)=(611,  211,  211)(1.81,0.60,0.60).P_- = -\frac{2}{\sqrt{11}}(3,1,-1) = \left(-\frac{6}{\sqrt{11}},\; -\frac{2}{\sqrt{11}},\; \frac{2}{\sqrt{11}}\right) \approx (-1.81,\, -0.60,\, 0.60).

Distances from (3,1,1)(3,1,-1):

The point (3,1,1)(3,1,-1) lies at distance 11\sqrt{11} from the origin. Therefore:

  • P+P_+ is in the same direction as (3,1,1)(3,1,-1): distance =112= \sqrt{11} - 2 (closest).
  • PP_- is in the opposite direction: distance =11+2= \sqrt{11} + 2 (farthest).

8. Exercises

Solution.

f=1,1,1\nabla f = \langle 1,1,1 \rangle and g=2x,2y,2z\nabla g = \langle 2x,2y,2z \rangle.

Lagrange condition: 1=2λx1 = 2\lambda x, 1=2λy1 = 2\lambda y, 1=2λz1 = 2\lambda z.

So x=y=z=12λx = y = z = \frac{1}{2\lambda}. Substituting into g=1g = 1:

314λ2=1    λ=±32.3 \cdot \frac{1}{4\lambda^2} = 1 \implies \lambda = \pm\frac{\sqrt{3}}{2}.

  • λ=32\lambda = \frac{\sqrt{3}}{2}: (x,y,z)=(13,13,13)(x,y,z) = \left(\frac{1}{\sqrt{3}}, \frac{1}{\sqrt{3}}, \frac{1}{\sqrt{3}}\right), f=3f = \sqrt{3}maximum.
  • λ=32\lambda = -\frac{\sqrt{3}}{2}: (x,y,z)=(13,13,13)(x,y,z) = \left(-\frac{1}{\sqrt{3}}, -\frac{1}{\sqrt{3}}, -\frac{1}{\sqrt{3}}\right), f=3f = -\sqrt{3}minimum.

Solution.

f=y,x\nabla f = \langle y, x \rangle and g=2x,8y\nabla g = \langle 2x, 8y \rangle.

Lagrange conditions: y=2λxy = 2\lambda x and x=8λyx = 8\lambda y.

Substituting: x=8λ(2λx)=16λ2xx = 8\lambda(2\lambda x) = 16\lambda^2 x.

If x0x \neq 0: λ2=1/16\lambda^2 = 1/16, so λ=±1/4\lambda = \pm 1/4.

For λ=1/4\lambda = 1/4: y=x/2y = x/2. On the constraint: x2+4(x/2)2=4    2x2=4    x=±2x^2 + 4(x/2)^2 = 4 \implies 2x^2 = 4 \implies x = \pm\sqrt{2}.

Points: (2,22)(\sqrt{2}, \frac{\sqrt{2}}{2}) and (2,22)(-\sqrt{2}, -\frac{\sqrt{2}}{2}), both with f=1f = 1.

For λ=1/4\lambda = -1/4: y=x/2y = -x/2, giving points (2,22)(\sqrt{2}, -\frac{\sqrt{2}}{2}) and (2,22)(-\sqrt{2}, \frac{\sqrt{2}}{2}), both with f=1f = -1.

Maximum 11, minimum 1-1.

Problem. A rectangular box with dimensions x,y,z>0x, y, z > 0 has surface area 2(xy+yz+xz)=62(xy + yz + xz) = 6. Find the dimensions that maximize the volume V=xyzV = xyz.

Solution.

Maximize f=xyzf = xyz subject to g=xy+yz+xz=3g = xy + yz + xz = 3.

f=yz,xz,xy,g=y+z,x+z,x+y.\nabla f = \langle yz, xz, xy \rangle, \qquad \nabla g = \langle y+z, x+z, x+y \rangle.

Lagrange conditions: yz=λ(y+z),xz=λ(x+z),xy=λ(x+y).yz = \lambda(y+z), \quad xz = \lambda(x+z), \quad xy = \lambda(x+y).

By symmetry, try x=y=zx = y = z. Then each equation becomes x2=2λxx^2 = 2\lambda x, so λ=x/2\lambda = x/2.

Constraint: 3x2=3    x=13x^2 = 3 \implies x = 1.

The box is a cube with x=y=z=1x = y = z = 1 and maximum volume V=1V = 1.

Problem. Find the point on the plane x+2y+3z=6x + 2y + 3z = 6 closest to the origin.

Solution.

Minimize f=x2+y2+z2f = x^2 + y^2 + z^2 subject to g=x+2y+3z=6g = x + 2y + 3z = 6.

f=2x,2y,2z,g=1,2,3.\nabla f = \langle 2x, 2y, 2z \rangle, \qquad \nabla g = \langle 1, 2, 3 \rangle.

Lagrange: 2x=λ2x = \lambda, 2y=2λ2y = 2\lambda, 2z=3λ2z = 3\lambda.

So x=λ/2x = \lambda/2, y=λy = \lambda, z=3λ/2z = 3\lambda/2.

Substitute into the constraint:

λ2+2λ+9λ2=6    λ(12+2+92)=6    7λ=6    λ=67.\frac{\lambda}{2} + 2\lambda + \frac{9\lambda}{2} = 6 \implies \lambda\left(\frac{1}{2} + 2 + \frac{9}{2}\right) = 6 \implies 7\lambda = 6 \implies \lambda = \frac{6}{7}.

Closest point: (37,67,97)\left(\frac{3}{7}, \frac{6}{7}, \frac{9}{7}\right). Distance to origin: 614\frac{6}{\sqrt{14}}.