Lagrange Multipliers Calculator

Published on: July 21, 2026
Final Answer: Free | Full Steps: Pro

This Lagrange Multipliers Calculator finds the largest and smallest values a function can take while a constraint is obeyed, and shows the working line by line. At such a point the two gradients line up, because otherwise you could still slide along the constraint and improve. Setting one gradient to a multiple of the other gives the equations to solve. Following the same pattern every time keeps the constraint in play throughout.

Step-by-step method

  1. Set up the problem.
  2. Write the formula.
  3. Find the gradients of f and g.
  4. Write the Lagrange system.
  5. Remove lambda and solve.
  6. Evaluate f at each solution.

Formula: Lagrange Multiplier Conditions

At a maximum or minimum on the constraint, the gradient of f is a multiple of the gradient of g, and the point satisfies the constraint.

\(\nabla f = \lambda \nabla g,\quad g(x, y) = k\)

Useful Tips to Remember

Always include the constraint \(g(x, y) = k\) as one of the equations, or the system cannot be solved. The number \(\lambda\) is only a helper, and the answer is the values of f at the solutions. Compare f at every solution to find the maximum and the minimum. If the constraint curve is closed, like a circle, both a maximum and a minimum always exist.

Required knowledge

Where Are Lagrange Multipliers Used?

Lagrange multipliers find the best value of something when there is a limit to obey, which is how most real optimisation problems look. Economists maximise utility or output under a fixed budget. Engineers minimise cost or weight while meeting a strength or volume requirement. In physics, constrained motion and the shapes of hanging chains and soap films come from the same idea, and machine learning uses it in support vector machines.

  • Maximising utility under a budget in economics
  • Minimising cost for a required volume or strength
  • Constrained motion in physics
  • Support vector machines in machine learning
  • Finding the closest point on a curve or surface

Lagrange Multipliers Practice Problems

Example 1 finds the extreme values of \(x y\) on the circle \(x^{2} + y^{2} = 1\), and Example 2 uses \(x + y\) on \(x^{2} + y^{2} = 2\). Set up the system, solve it and compare the values of f. For two more free worked examples, check out the Lagrange Multipliers Notes.

The worked examples below go through the same pattern from start to finish, so you can compare every step with your own working. For more practice, the notes page goes further with extra worked examples and fuller explanations of the ideas behind each step. Use them together to check your answers and to understand why each step works.

See Example 1 Hide Example 1

Problem

\(f(x, y) = x y,\; x^{2} + y^{2} = 1\)

Approach

Step-by-step method

  1. Set up the problem.
  2. Write the formula.
  3. Find the gradients of f and g.
  4. Write the Lagrange system.
  5. Remove lambda and solve.
  6. Evaluate f at each solution.

Formula

Formula: Lagrange Multiplier Conditions

At a maximum or minimum on the constraint, the gradient of f is a multiple of the gradient of g, and the point satisfies the constraint.

\(\nabla f = \lambda \nabla g,\quad g(x, y) = k\)

Step 1

Step 1 - Set up the problem.

In this problem: We are finding the largest and smallest values of \(f(x, y) = x y\) on the curve \(x^{2} + y^{2} = 1\).

\(f(x, y) = x y,\; x^{2} + y^{2} = 1\)

Step 2

Step 2 - Write the formula.

In this problem: At a maximum or minimum on the constraint, the gradient of f points the same way as the gradient of g, so one is a multiple \(\lambda\) of the other.

\(\nabla f = \lambda \nabla g,\quad g(x, y) = k\)

Step 3

Step 3 - Find the gradients of f and g.

In this problem: Both gradients are needed, covered in the Gradient Calculator, so each one is found in turn.

\(\nabla f,\; \nabla g\)

Step 3a

Step 3a - Find the gradient of f.

In this problem: Differentiating f with respect to x and y gives \(\nabla f = \left\langle y,\; x \right\rangle\).

\(\nabla f = \left\langle y,\; x \right\rangle\)

Step 3b

Step 3b - Find the gradient of g.

In this problem: Differentiating g with respect to x and y gives \(\nabla g = \left\langle 2 x,\; 2 y \right\rangle\).

\(\nabla g = \left\langle 2 x,\; 2 y \right\rangle\)

Step 4

Step 4 - Write the Lagrange system.

In this problem: Matching the components of \(\nabla f = \lambda \nabla g\) and adding the constraint gives three equations in x, y and \(\lambda\).

\(\begin{cases} y = 2 \lambda x \\ x = 2 \lambda y \\ x^{2} + y^{2} = 1 \end{cases}\)

Step 5

Step 5 - Remove lambda and solve.

In this problem: Multiplying the first equation by \(2 y\) and the second by \(2 x\) makes the \(\lambda\) terms on the right the same, so subtracting removes \(\lambda\) and leaves \(\left(y\right)\left(2 y\right) - \left(x\right)\left(2 x\right) = - 2 x^{2} + 2 y^{2} = 0\). Solving this together with the constraint, covered in the Nonlinear System of Equations Calculator, gives the points \(\left(- \frac{\sqrt{2}}{2},\; - \frac{\sqrt{2}}{2}\right)\), \(\left(- \frac{\sqrt{2}}{2},\; \frac{\sqrt{2}}{2}\right)\), \(\left(\frac{\sqrt{2}}{2},\; - \frac{\sqrt{2}}{2}\right)\) and \(\left(\frac{\sqrt{2}}{2},\; \frac{\sqrt{2}}{2}\right)\).

\(\begin{cases} - 2 x^{2} + 2 y^{2} = 0 \\ x^{2} + y^{2} = 1 \end{cases} \;\Rightarrow\; \left(- \frac{\sqrt{2}}{2},\; - \frac{\sqrt{2}}{2}\right),\; \left(- \frac{\sqrt{2}}{2},\; \frac{\sqrt{2}}{2}\right),\; \left(\frac{\sqrt{2}}{2},\; - \frac{\sqrt{2}}{2}\right),\; \left(\frac{\sqrt{2}}{2},\; \frac{\sqrt{2}}{2}\right)\)

Step 6

Step 6 - Evaluate f at each solution.

In this problem: Putting each point into f gives \(f\left(- \frac{\sqrt{2}}{2},\; - \frac{\sqrt{2}}{2}\right) = \left(- \frac{\sqrt{2}}{2}\right) \times {\left(- \frac{\sqrt{2}}{2}\right)} = \frac{1}{2}\), \(f\left(- \frac{\sqrt{2}}{2},\; \frac{\sqrt{2}}{2}\right) = \left(- \frac{\sqrt{2}}{2}\right) \times {\frac{\sqrt{2}}{2}} = - \frac{1}{2}\), \(f\left(\frac{\sqrt{2}}{2},\; - \frac{\sqrt{2}}{2}\right) = \frac{\sqrt{2}}{2} \times {\left(- \frac{\sqrt{2}}{2}\right)} = - \frac{1}{2}\) and \(f\left(\frac{\sqrt{2}}{2},\; \frac{\sqrt{2}}{2}\right) = \frac{\sqrt{2}}{2} \times {\frac{\sqrt{2}}{2}} = \frac{1}{2}\). The largest value is the maximum and the smallest is the minimum.

\(\text{max } f = \frac{1}{2} \text{ at } \left(- \frac{\sqrt{2}}{2},\; - \frac{\sqrt{2}}{2}\right),\; \left(\frac{\sqrt{2}}{2},\; \frac{\sqrt{2}}{2}\right),\quad \text{min } f = - \frac{1}{2} \text{ at } \left(- \frac{\sqrt{2}}{2},\; \frac{\sqrt{2}}{2}\right),\; \left(\frac{\sqrt{2}}{2},\; - \frac{\sqrt{2}}{2}\right)\)

Final Answer

\(\text{max } f = \frac{1}{2} \text{ at } \left(- \frac{\sqrt{2}}{2},\; - \frac{\sqrt{2}}{2}\right),\; \left(\frac{\sqrt{2}}{2},\; \frac{\sqrt{2}}{2}\right),\quad \text{min } f = - \frac{1}{2} \text{ at } \left(- \frac{\sqrt{2}}{2},\; \frac{\sqrt{2}}{2}\right),\; \left(\frac{\sqrt{2}}{2},\; - \frac{\sqrt{2}}{2}\right)\)
See Example 2 Hide Example 2

Problem

\(f(x, y) = x + y,\; x^{2} + y^{2} = 2\)

Approach

Step-by-step method

  1. Set up the problem.
  2. Write the formula.
  3. Find the gradients of f and g.
  4. Write the Lagrange system.
  5. Remove lambda and solve.
  6. Evaluate f at each solution.

Formula

Formula: Lagrange Multiplier Conditions

At a maximum or minimum on the constraint, the gradient of f is a multiple of the gradient of g, and the point satisfies the constraint.

\(\nabla f = \lambda \nabla g,\quad g(x, y) = k\)

Step 1

Step 1 - Set up the problem.

In this problem: We are finding the largest and smallest values of \(f(x, y) = x + y\) on the curve \(x^{2} + y^{2} = 2\).

\(f(x, y) = x + y,\; x^{2} + y^{2} = 2\)

Step 2

Step 2 - Write the formula.

In this problem: At a maximum or minimum on the constraint, the gradient of f points the same way as the gradient of g, so one is a multiple \(\lambda\) of the other.

\(\nabla f = \lambda \nabla g,\quad g(x, y) = k\)

Step 3

Step 3 - Find the gradients of f and g.

In this problem: Both gradients are needed, covered in the Gradient Calculator, so each one is found in turn.

\(\nabla f,\; \nabla g\)

Step 3a

Step 3a - Find the gradient of f.

In this problem: Differentiating f with respect to x and y gives \(\nabla f = \left\langle 1,\; 1 \right\rangle\).

\(\nabla f = \left\langle 1,\; 1 \right\rangle\)

Step 3b

Step 3b - Find the gradient of g.

In this problem: Differentiating g with respect to x and y gives \(\nabla g = \left\langle 2 x,\; 2 y \right\rangle\).

\(\nabla g = \left\langle 2 x,\; 2 y \right\rangle\)

Step 4

Step 4 - Write the Lagrange system.

In this problem: Matching the components of \(\nabla f = \lambda \nabla g\) and adding the constraint gives three equations in x, y and \(\lambda\).

\(\begin{cases} 1 = 2 \lambda x \\ 1 = 2 \lambda y \\ x^{2} + y^{2} = 2 \end{cases}\)

Step 5

Step 5 - Remove lambda and solve.

In this problem: Multiplying the first equation by \(2 y\) and the second by \(2 x\) makes the \(\lambda\) terms on the right the same, so subtracting removes \(\lambda\) and leaves \(\left(1\right)\left(2 y\right) - \left(1\right)\left(2 x\right) = - 2 x + 2 y = 0\). Solving this together with the constraint, covered in the Nonlinear System of Equations Calculator, gives the points \(\left(-1,\; -1\right)\) and \(\left(1,\; 1\right)\).

\(\begin{cases} - 2 x + 2 y = 0 \\ x^{2} + y^{2} = 2 \end{cases} \;\Rightarrow\; \left(-1,\; -1\right),\; \left(1,\; 1\right)\)

Step 6

Step 6 - Evaluate f at each solution.

In this problem: Putting each point into f gives \(f\left(-1,\; -1\right) = \left(-1\right) + {\left(-1\right)} = -2\) and \(f\left(1,\; 1\right) = 1 + {1} = 2\). The largest value is the maximum and the smallest is the minimum.

\(\text{max } f = 2 \text{ at } \left(1,\; 1\right),\quad \text{min } f = -2 \text{ at } \left(-1,\; -1\right)\)

Final Answer

\(\text{max } f = 2 \text{ at } \left(1,\; 1\right),\quad \text{min } f = -2 \text{ at } \left(-1,\; -1\right)\)

Notes and Practice Mode

Example Problems

Click one to load it into the box and solve it.