Math Core

Lesson 3.8 · Partial Derivatives

Lagrange multipliers

Many optimization problems come with a condition attached. Maximize the volume of a box, given a fixed amount of cardboard. Minimize the cost of a fence, given the area it must enclose. Find the hottest point, but only on a circular wire. The previous lesson handled boundaries by substituting and reducing to one variable, which can get messy fast. The method of Lagrange multipliers handles constraints directly, using nothing more than the gradient.

The geometric idea

Suppose you want the largest value of f(x,y)f(x, y) among the points on the constraint curve g(x,y)=kg(x, y) = k. Picture the level curves f(x,y)=cf(x, y) = c drawn on top of the constraint curve.

The constraint circle x² + y² = 8 with level curves xy = 2, 4, 6 of f(x, y) = xy. The level curve xy = 4 just touches the circle at (2, 2) and (−2, −2).Open in grapher →

Walk along the constraint curve. As long as you are crossing level curves of ff, you can keep walking toward higher values, so you are not at a maximum. The largest value is reached where the constraint curve stops crossing level curves and instead just touches one: the level curve of ff and the constraint curve are tangent there. In the picture, xy=6xy = 6 misses the circle, xy=2xy = 2 crosses it, and xy=4xy = 4 touches it.

Two curves that are tangent at a point share a tangent line, so their normal lines agree too. The gradient is normal to level curves, so at that point ∇f\nabla f and ∇g\nabla g are parallel.

Method of Lagrange multipliers

To find the maximum and minimum values of f(x,y)f(x, y) (or f(x,y,z)f(x, y, z)) subject to g=kg = k, assuming these extreme values exist and ∇g≠0\nabla g \ne \mathbf{0} on the constraint:

  1. Find all points and numbers λ\lambda satisfying
∇f=λ ∇gandg=k.\nabla f = \lambda\,\nabla g \qquad\text{and}\qquad g = k.
  1. Evaluate ff at every point found in step 1. The largest value is the maximum; the smallest is the minimum.

The number λ\lambda is the Lagrange multiplier. In two variables, step 1 is a system of three equations in three unknowns xx, yy, λ\lambda:

fx=λgx,fy=λgy,g(x,y)=k.f_x = \lambda g_x, \qquad f_y = \lambda g_y, \qquad g(x, y) = k.

You usually don't need the value of λ\lambda itself; it is a tool for finding xx and yy.

Worked example: A product on a circle

Find the maximum and minimum of f(x,y)=xyf(x, y) = xy on the circle x2+y2=8x^2 + y^2 = 8.

Here g=x2+y2g = x^2 + y^2, so ∇f=⟨y,x⟩\nabla f = \langle y, x\rangle and ∇g=⟨2x,2y⟩\nabla g = \langle 2x, 2y\rangle. The system is

y=2λx,x=2λy,x2+y2=8.y = 2\lambda x, \qquad x = 2\lambda y, \qquad x^2 + y^2 = 8.

Multiply the first equation by yy and the second by xx: y2=2λxyy^2 = 2\lambda xy and x2=2λxyx^2 = 2\lambda xy. So x2=y2x^2 = y^2. (If x=0x = 0, the first equation forces y=0y = 0, which is not on the circle, so this is safe.) Then 2x2=82x^2 = 8 gives x=±2x = \pm 2 and y=±2y = \pm 2, which yields four points.

point(2,2)(2, 2)(−2,−2)(-2, -2)(2,−2)(2, -2)(−2,2)(-2, 2)
f=xyf = xy4444−4-4−4-4

The maximum is 44 and the minimum is −4-4.

Worked example: A line across an ellipse

Find the extreme values of f(x,y)=2x+yf(x, y) = 2x + y on the ellipse x2+4y2=17x^2 + 4y^2 = 17.

∇f=⟨2,1⟩\nabla f = \langle 2, 1\rangle and ∇g=⟨2x,8y⟩\nabla g = \langle 2x, 8y\rangle, so

2=2λx,1=8λy,x2+4y2=17.2 = 2\lambda x, \qquad 1 = 8\lambda y, \qquad x^2 + 4y^2 = 17.

Neither λ\lambda, xx nor yy can be zero, so x=1λx = \dfrac{1}{\lambda} and y=18λy = \dfrac{1}{8\lambda}. Substitute into the constraint:

1λ2+464λ2=1716λ2=17⟹λ2=116,λ=±14.\frac{1}{\lambda^2} + \frac{4}{64\lambda^2} = \frac{17}{16\lambda^2} = 17 \quad\Longrightarrow\quad \lambda^2 = \frac{1}{16}, \quad \lambda = \pm\frac{1}{4}.

λ=14\lambda = \tfrac{1}{4} gives (4,12)\left(4, \tfrac{1}{2}\right) with f=172f = \tfrac{17}{2}; λ=−14\lambda = -\tfrac{1}{4} gives (−4,−12)\left(-4, -\tfrac{1}{2}\right) with f=−172f = -\tfrac{17}{2}. The maximum is 172\tfrac{17}{2} and the minimum is −172-\tfrac{17}{2}.

Three variables

The method is identical with three variables, but now there are four equations: fx=λgxf_x = \lambda g_x, fy=λgyf_y = \lambda g_y, fz=λgzf_z = \lambda g_z and g=kg = k. The geometry is that the level surface of ff is tangent to the constraint surface.

Worked example: The best closed box

A closed rectangular box must have a total surface area of 2424 square meters. What is its largest possible volume?

Maximize V=xyzV = xyz subject to g=2xy+2yz+2xz=24g = 2xy + 2yz + 2xz = 24, with x,y,z>0x, y, z > 0. The Lagrange equations are

yz=λ(2y+2z),xz=λ(2x+2z),xy=λ(2x+2y).yz = \lambda(2y + 2z), \qquad xz = \lambda(2x + 2z), \qquad xy = \lambda(2x + 2y).

Multiply the first by xx, the second by yy, and the third by zz. All three left sides become xyzxyz, so

λ(2xy+2xz)=λ(2xy+2yz)=λ(2xz+2yz).\lambda(2xy + 2xz) = \lambda(2xy + 2yz) = \lambda(2xz + 2yz).

λ≠0\lambda \ne 0 (otherwise yz=0yz = 0), so cancel it. The first equality gives xz=yzxz = yz, so x=yx = y; the second gives xy=xzxy = xz, so y=zy = z. The box is a cube. Then 6x2=246x^2 = 24, so x=2x = 2, and the maximum volume is 23=82^3 = 8 cubic meters.

Common mistake

Lagrange's method finds candidates, and it assumes the extreme values exist. On a closed, bounded constraint such as a circle, ellipse or sphere, existence is guaranteed, so comparing the values of ff settles everything. On an unbounded constraint (a line, a hyperbola, a plane), one of the extremes may not exist at all. For example, f=x2+y2f = x^2 + y^2 on xy=1xy = 1 has a minimum of 22 but no maximum, because points on the hyperbola can be arbitrarily far from the origin.

Tip

When solving the Lagrange system, a reliable trick is to eliminate λ\lambda by solving each equation for λ\lambda and setting the results equal, or by multiplying equations so that the same product appears on both sides, as in the box example. Watch for cases where you would divide by zero, and handle them separately.

Practice

Practice 1

Find the maximum value of f(x,y)=x+yf(x, y) = x + y subject to x2+y2=18x^2 + y^2 = 18.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 2

Find the minimum value of f(x,y)=x2+y2f(x, y) = x^2 + y^2 subject to x+2y=10x + 2y = 10.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 3

Find the maximum value of f(x,y)=xyf(x, y) = xy subject to 2x+y=122x + y = 12, where x>0x > 0 and y>0y > 0.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 4

Find the maximum value of f(x,y)=x2yf(x, y) = x^2y on the circle x2+y2=3x^2 + y^2 = 3.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 5

Find the minimum value of f(x,y,z)=x−2y+2zf(x, y, z) = x - 2y + 2z on the sphere x2+y2+z2=9x^2 + y^2 + z^2 = 9.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 6

Find the maximum value of f(x,y,z)=xyzf(x, y, z) = xyz subject to x+y+z=12x + y + z = 12, where x,y,z>0x, y, z > 0.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 7

A rectangle with sides parallel to the axes is inscribed in the ellipse x24+y2=1\dfrac{x^2}{4} + y^2 = 1, with one corner at (x,y)(x, y) in the first quadrant. Find the largest possible area of the rectangle.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 8

Consider f(x,y)=x2+y2f(x, y) = x^2 + y^2 subject to xy=1xy = 1. Which statement is correct?