Multivariable Calculus · Undergraduate

Lagrange Multipliers

Quick answer

To find the largest or smallest value of f(x, y) subject to a constraint g(x, y) = k, look for points where the gradients are parallel: ∇f = λ∇g, with g = k. At such a point a level curve of f touches the constraint curve without crossing it, which is exactly what happens at a constrained maximum or minimum. The multiplier λ is an extra unknown; solving the equations gives candidate points, and comparing f at them picks out the answers. The method extends to three variables unchanged.

What you'll learn

  • Set up the Lagrange equations for a constrained problem
  • Explain why the gradients are parallel at the optimum
  • Solve for candidate points and compare values
  • Apply the method to geometry and economics problems

Optimizing along a curve

Maximize f(x,y)=xyf(x, y) = xy when x+y=10x + y = 10. The points allowed form a line, not the whole plane, so setting ∇f=0\nabla f = \mathbf{0} does not help: the answer need not be a critical point of ff. The constraint g(x,y)=x+y=10g(x, y) = x + y = 10 restricts where to look.

Lagrange’s method. The extreme values of ff on the curve g(x,y)=kg(x, y) = k occur at points where

∇f=λ∇g\nabla f = \lambda\nabla g and g(x,y)=kg(x, y) = k

for some number λ\lambda, called the Lagrange multiplier.

Why the gradients line up

Picture the level curves of ff drawn over the constraint curve. Moving along the constraint, ff increases as the constraint crosses higher and higher level curves. As long as the constraint crosses a level curve, there is a higher one still reachable. The largest value is reached at the last level curve the constraint meets, which it touches without crossing. Two curves that touch share a tangent line there. The gradients are perpendicular to their curves, so ∇f\nabla f and ∇g\nabla g lie along the same line. At a constrained maximum or minimum, a level curve of ff is tangent to the constraint, so the gradients are parallel: ∇f=λ∇g\nabla f = \lambda\nabla g.

Level curves of xy against the constraint x + y = 10 The line x + y = 10 and three level curves of xy, the hyperbolas xy = 16, xy = 25 and xy = 36. The hyperbola xy = 16 crosses the line twice; xy = 36 misses it entirely; and xy = 25 touches it at exactly one point, (5, 5), the constrained maximum. 246810246810xy (5, 5)
  • x + y = 10
  • xy = 16
  • xy = 25
  • xy = 36
Level curves of xy against the constraint x + y = 10

Worked examples

Common mistakes

Practice problems

  1. Maximize x+yx + y subject to x2+y2=2x^2 + y^2 = 2.

    Answer

    22, at (1,1)(1, 1)

    Full solution

    1=2λx1 = 2\lambda x and 1=2λy1 = 2\lambda y give x=yx = y, and 2x2=22x^2 = 2 gives x=±1x = \pm 1. The value is 22 at (1,1)(1, 1) and −2-2 at (−1,−1)(-1, -1), the minimum.

  2. Minimize x2+y2x^2 + y^2 subject to x+y=4x + y = 4.

    Answer

    88, at (2,2)(2, 2)

    Full solution

    2x=λ2x = \lambda and 2y=λ2y = \lambda give x=y=2x = y = 2.

  3. A rectangle has area 1616. Use Lagrange multipliers to find the least possible perimeter.

    Answer

    1616, for the 4×44 \times 4 square

    Full solution

    Minimize 2x+2y2x + 2y subject to xy=16xy = 16: 2=λy2 = \lambda y and 2=λx2 = \lambda x give x=yx = y, so x2=16x^2 = 16 and x=4x = 4.

  4. Maximize 3x+4y3x + 4y on the circle x2+y2=1x^2 + y^2 = 1.

    Answer

    55, at (0.6,0.8)(0.6, 0.8)

    Full solution

    3=2λx3 = 2\lambda x and 4=2λy4 = 2\lambda y give (x,y)(x, y) parallel to (3,4)(3, 4). The unit vector in that direction is (0.6,0.8)(0.6, 0.8), where 3x+4y=1.8+3.2=53x + 4y = 1.8 + 3.2 = 5.

  5. Maximize xyzxyz subject to x+y+z=6x + y + z = 6 with all positive.

    Answer

    88, at (2,2,2)(2, 2, 2)

    Full solution

    As in Example 4, the equations force x=y=zx = y = z, so each is 22.

  6. Write the Lagrange equations for maximizing f(x,y)=x2yf(x, y) = x^2y subject to x+y=3x + y = 3.

    Answer

    2xy=λ2xy = \lambda, x2=λx^2 = \lambda, x+y=3x + y = 3

    Full solution

    ∇f=(2xy,x2)\nabla f = (2xy, x^2) and ∇g=(1,1)\nabla g = (1, 1). Setting 2xy=x22xy = x^2 with x≠0x \ne 0 gives x=2yx = 2y, so y=1y = 1, x=2x = 2 and f=4f = 4.

  7. In the figure, why is xy=16xy = 16 not the answer?

    Answer

    It crosses the line, so higher level curves are still reachable.

    Full solution

    Between its two crossings, at (2,8)(2, 8) and (8,2)(8, 2), the line passes through points where xy>16xy > 16. Only a level curve that touches the line without crossing can mark the maximum.

  8. What does the constraint x+y=10x + y = 10 look like on the level curves of f(x,y)=x+yf(x, y) = x + y? What does Lagrange’s method give?

    Answer

    The constraint is a level curve of ff, so f=10f = 10 everywhere on it.

    Full solution

    ∇f=(1,1)=λ(1,1)\nabla f = (1, 1) = \lambda(1, 1) holds with λ=1\lambda = 1 at every point, so every point is a candidate, and every point gives the same value. The method is consistent with a constant function.

  9. Find the point of the line 2x+y=102x + y = 10 closest to the origin.

    Answer

    (4,2)(4, 2)

    Full solution

    Minimize x2+y2x^2 + y^2: 2x=2λ2x = 2\lambda and 2y=λ2y = \lambda give x=2yx = 2y, so 5y=105y = 10 and y=2y = 2. The distance is 20\sqrt{20}, matching 105\tfrac{10}{\sqrt{5}}.

  10. A student solves Example 1 by setting ∇(xy)=0\nabla(xy) = \mathbf{0} and finds only (0,0)(0, 0). What went wrong?

    Hint

    Is (0,0)(0, 0) on the line x+y=10x + y = 10?

    Answer

    The constraint was ignored. (0,0)(0, 0) is not even on the line; the method needs ∇f=λ∇g\nabla f = \lambda\nabla g.

    Full solution

    The unconstrained critical point of xyxy is a saddle at the origin, which does not satisfy x+y=10x + y = 10. Along the line, the extreme is where a level curve touches it, at (5,5)(5, 5).

Frequently asked questions

What is the method of Lagrange multipliers?

To optimize f(x, y) subject to g(x, y) = k, solve ∇f = λ∇g together with g = k, then compare the values of f at the solutions.

Why must the gradients be parallel?

At a constrained extreme, the level curve of f through the point touches the constraint curve. Touching curves share a tangent line, so their normals, the gradients, point along the same line.

What is λ?

An extra unknown, the Lagrange multiplier. It usually is not needed in the final answer, but it measures how fast the optimal value changes as the constraint level k changes.

How do you tell the maximum from the minimum?

Evaluate f at every candidate point. On a closed, bounded constraint curve, the largest value is the maximum and the smallest is the minimum.

Does the method work in three variables?

Yes. Solve ∇f = λ∇g with g(x, y, z) = k: four equations in the four unknowns x, y, z and λ.

What to learn next