Skip to content
LoveToCalc

Theorem — what does that mean?

Lagrange multipliers

To find the largest or smallest value of f(x, y) along a curve g(x, y) = c, look for the points where the two gradients line up.

In Swedish: Lagranges multiplikatormetod

(∂f∂x, ∂f∂y)=(λ∂g∂x, λ∂g∂y)

x
The first variable
y
The second variable
λ
The Lagrange multiplier

The condition

The two vectors are the gradients of f and of g, and λ is a number, the Lagrange multiplier. Written out, the condition is fx = λ · gx and fy = λ · gy. Together with the constraint g(x, y) = c these are three equations in the three unknowns x, y and λ, and their solutions are the candidates. The page has no card: the work is solving that system, and a card that took the four partial derivatives and λ would either hand one of them back or have no answer unless they were already parallel.

Holds when f and g have continuous first partial derivatives near the point, the point is a local maximum or minimum of f among the points of the curve g = c, and ∇g is not the zero vector there. It is a necessary condition, not a sufficient one: it produces candidates, and the candidates still have to be compared.

Why the gradients line up

The gradient of g is perpendicular to the curve g = c. If f has a local extremum on the curve, then f does not change to first order when you move along the curve, so ∇f is perpendicular to the curve as well. In the plane, two vectors perpendicular to the same direction are multiples of each other. In terms of level curves: at the point, the curve g = c and the level curve of f through it touch without crossing.

The method

  1. Write the constraint as g(x, y) = c, and compute ∇f and ∇g.
  2. Solve fx = λgx, fy = λgy and g = c for x, y and λ.
  3. Add the points where ∇g = 0 on the curve, if there are any, since the condition cannot find them.
  4. Compare f at all candidates. If the curve is closed and bounded, the largest value is the maximum and the smallest is the minimum. If it is not, there may be no maximum or minimum at all.

Worked example: xy on an ellipse

Find the largest and smallest values of f = xy on the ellipse g = x² + 4y² = 8. Here ∇f = (y, x) and ∇g = (2x, 8y), so

Putting the first into the second gives x = 16λ²x. Here x ≠ 0, since x = 0 would force y = 0, which is not on the ellipse, so λ² = 1/16 and λ = ±1/4.

The ellipse is closed and bounded, so the largest value is 2 and the smallest is −2. The inequality x² + 4y² ≥ 4|xy| gives the same bound.

A second example: x + y on a circle

For f = x + y on x² + y² = 2, ∇f = (1, 1) and ∇g = (2x, 2y), so 1 = 2λx and 1 = 2λy. Then x = y = 1/(2λ), and x² + y² = 2 gives x² = 1: the candidates are (1, 1) with λ = 1/2 and (−1, −1) with λ = −1/2. The values of f are 2 and −2.

When the condition misses the answer

On the curve x² = y³ (a cusp with y ≥ 0), take f = y. The smallest value is 0, at the origin. There g = x² − y³ has ∇g = (2x, −3y²) = (0, 0), while ∇f = (0, 1), so no λ satisfies ∇f = λ∇g. The method does not find this point, which is why step 3 asks for the points where ∇g = 0.

What λ means

When the optimum depends differentiably on the constraint level c, λ is the rate at which the optimal value changes with c. For f = xy on 2x + y = c, the maximum is c²/8, at (c/4, c/2), where fx = y = 2λ gives λ = c/4, which is the derivative of c²/8. At c = 8 the maximum is 8, at (2, 4), and λ = 2.

Common mistakes

Frequently asked questions

What is the Lagrangian? The function L(x, y, λ) = f − λ(g − c). Setting its three partial derivatives to 0 gives the same three equations as above, so a candidate is a stationary point of L.

Can I substitute the constraint instead? When the constraint can be solved for one variable, as y = 8 − 2x, putting it into f gives a function of one variable with the usual tools. The multiplier method is for constraints that are awkward to solve, and it treats the variables alike.

How do I know whether a candidate is a maximum or a minimum? Compare the values of f at all candidates, as in the example. A second-order test for a constraint exists (it uses a bordered Hessian), but when the curve is closed and bounded, comparing values is enough.

Last reviewed November 8, 2026 ·How pages are reviewed

CalculusAll formulas