Lagrange Multipliers Explained with Worked Examples

To optimise subject to , solve together with the constraint .

Write 2x or 2*x to multiply, ^ for powers, and ; between simultaneous equations. You can also type factor, expand, derivative of, integrate … from a to b, limit … as x->0 or 15% of 80.

Try an example

Before you start

This page is easier if you are comfortable with:

What Lagrange multipliers means

At a constrained maximum or minimum, the level curve of is tangent to the constraint curve, so the gradients are parallel: for some multiplier .

This gives equations in , and , which you solve with the constraint.

The multiplier has a meaning: it measures how the optimal value changes with . At a constrained extremum the gradients are parallel, the nature of the point can be tested with the Hessian test, and the one-variable idea is stationary points. A closely connected idea is Partial derivatives commute.

This page is part of Multivariable calculus in Calculus. Topics that work alongside it: Hessian and second-derivative test, Gradient and directional derivative, Stationary points, Jacobian for a change of variables, Double integral in polar coordinates and Spherical coordinates.

What is it used for?

Lagrange multipliers find the maximum or minimum of a function subject to a constraint, by requiring that the gradients of the function and the constraint are parallel.

How to use lagrange multipliers

  1. Write component by component.
  2. Add the constraint equation.
  3. Solve the system.
  4. Evaluate at each solution and compare.

Graph

Maximise xy on the line x + y = 100123456789100246810Maximise xy on the line x + y = 10xyx + y = 10xy = 25xy = 16Graph with x from 0 to 10 and y from 0 to 10. Shows the curve x + y = 10; the curve xy = 25; the curve xy = 16.

The largest value of xy that still touches the line is where the curve xy = 25 just touches it, at (5, 5).

Worked examples

These examples are worked by hand, step by step, so you can compare your own working.

Example 1: maximise a product

Maximise subject to .

Worked example
Answer
x=y=5, f=25x=y=5,\ f=25
  1. Set up
  2. Equations
  3. Solve
  4. Maximum value

Example 2: a point on a line closest to the origin

Minimise subject to .

Worked example
Answer
x=y=1, f=2x=y=1,\ f=2
  1. Set up
  2. Solve
  3. Minimum value

Example 3: a constraint 2x + y = 8

Maximise subject to .

Worked example
Answer
maximum f=8 at (2, 4)\text{maximum } f = 8 \text{ at } (2,\ 4)
  1. Set ∇f = λ∇g
  2. Use the constraint
  3. Evaluate f

Special cases

A few situations come up again and again. Knowing them saves time and helps you spot answers that cannot be right.

max xy with x + y = 10

x = y = 5

xy = 25, λ = 5.

min x² + y² with x + y = 2

x = y = 1

value 2.

max x + y on x² + y² = 2

x = y = 1

value 2.

Gradient condition

∇(xy) = (y, x) = λ(1, 1)

λ = 5.

Word problems

To optimise f subject to g = c, solve ∇f = λ∇g together with g = c. The multiplier λ is the rate of change of the optimum with c.

Equations

f = xy, g = x + y = 10: y = λ, x = λ so x = y. Find x.

  1. 2x = 10
  2. Check: ✓5

Optimum

Find xy at x = y = 5.

  1. 25
  2. Check: ✓25

Minimum distance Higher

min x² + y² with x + y = 2: value at (1, 1).

  1. 1 + 1
  2. Check: ✓2

Multiplier Higher

Find λ = x for xy with x + y = 10.

  1. 5
  2. Check: ✓5

Common mistakes

Forgetting the constraint

only ∇f = λ∇g ✗

also g = c ✓

Include it.

Not checking max vs min

assume ✗

compare values ✓

Test.

Mixing λ sign

sign conventions ✗

be consistent ✓

Check.

Missing solutions

x = 0 case ✗

consider all cases ✓

Divide carefully.

Exam tips

  1. ∇f = λ∇g.
  2. Add g = c.
  3. Solve the system.
  4. Compare values.
  5. λ measures sensitivity.

Practice questions

Try each one on paper, then open the answer. Use the solver above to see the full working.

1. max xy with x + y = 8 Foundation

16

2. min x² + y² with x + y = 4 Foundation

8

3. max xy with x + y = 12 Foundation

36

4. λ for max xy with x + y = 20 Higher

10

5. max x + y on x² + y² = 8 Higher

4

6. min x² + y² with x + y = 6 Higher

18

Practice generator

Unlimited fresh questions with instant marking. Choose a level, work it out on paper, then type your answer.

Solve: …

Key terms

Lagrange multiplier (λ)
Constraint weight.
Constraint
g(x, y) = c.
Gradient
∇f.
Critical point
Candidate optimum.
Constrained optimisation
Optimising on a curve.
Level curve
g = c.

Frequently asked questions

What are Lagrange multipliers?

A method for optimising f subject to g = c.

What equations do I solve?

∇f = λ∇g and g = c.

What does λ mean?

The rate of change of the optimum with c.

Do I check endpoints?

Compare all candidate values.

Which page covers the Hessian?

Hessian and second derivative test.

Which page covers polar double integrals?

double integrals in polar coordinates.

More in Calculus and the formula sheets.