Lagrange Multiplier Calculator is loading…
It finds the largest and smallest values of a function \(f(x, y)\) when the point must stay on a constraint \(g(x, y) = c\). You solve \(\nabla f = \lambda \nabla g\) together with \(g = c\), then compare \(f\) at every solution. For example, the maximum of \(xy\) on the circle \(x^2 + y^2 = 8\) is 4, at \((2, 2)\) and \((-2, -2)\).
The Idea in One Picture
Picture the level curves of \(f\), like the contour lines on a hiking map, and the constraint curve \(g = c\) as a trail. As you walk the trail, \(f\) goes up and down. At the highest or lowest point on the trail, the trail just touches a contour line without crossing it. At that touching point, the two curves share a tangent line, so their gradients point in the same (or opposite) direction:
The number \(\lambda\) (lambda) is the Lagrange multiplier. It just says one gradient is a multiple of the other.
The Method in 4 Steps
- Find both gradients. \(\nabla f = \langle f_x, f_y\rangle\) and \(\nabla g = \langle g_x, g_y\rangle\). The partial derivative calculator can check these.
- Set up the system. \(f_x = \lambda g_x\), \(f_y = \lambda g_y\), and \(g = c\). That is 3 equations in 3 unknowns.
- Solve it. Often you divide or subtract equations to get rid of \(\lambda\) first.
- Compare values. Plug every solution into \(f\). The largest is the maximum and the smallest is the minimum.
Worked Example: Maximize \(xy\) on \(x^2 + y^2 = 8\)
Gradients: \(\nabla f = \langle y, x\rangle\) and \(\nabla g = \langle 2x, 2y\rangle\).
System: \(y = 2\lambda x\), \(x = 2\lambda y\), \(x^2 + y^2 = 8\).
Solve: Multiply the first equation by \(y\) and the second by \(x\): \(y^2 = 2\lambda xy = x^2\). So \(x^2 = y^2\), and the constraint gives \(2x^2 = 8\), so \(x = \pm 2\) and \(y = \pm 2\).
| Point | \(f = xy\) | Result |
|---|---|---|
| \((2, 2)\) | 4 | Maximum |
| \((-2, -2)\) | 4 | Maximum |
| \((2, -2)\) | \(-4\) | Minimum |
| \((-2, 2)\) | \(-4\) | Minimum |
The circle is a closed, bounded curve, so these really are the absolute maximum and minimum.
What Does \(\lambda\) Mean?
Lambda is more than a helper. It tells you how fast the best value of \(f\) changes if you loosen the constraint a little: \(\lambda \approx \frac{\Delta f_{\max}}{\Delta c}\). In economics this is called a shadow price. For example, if \(f\) is profit and \(c\) is your budget, \(\lambda\) is roughly the extra profit from one more dollar of budget.
Three Variables Work the Same Way
To maximize \(f = xyz\) with \(x + y + z = 12\), solve \(yz = \lambda\), \(xz = \lambda\), \(xy = \lambda\), and the constraint. Symmetry gives \(x = y = z = 4\), so the maximum is \(4^3 = 64\). This is the classic “box with the biggest volume” idea: for a fixed total, the product is largest when the numbers are equal.
Watch out for unbounded constraints. On a line like \(x + y = 4\), the function \(x^2 + y^2\) has a minimum (8, at \((2, 2)\)) but no maximum: it keeps growing as you walk along the line. Lagrange multipliers find candidates; they do not promise both a max and a min exist.
Learn the Math Behind the Lagrange Multiplier Calculator
Lagrange multipliers find the largest or smallest value of a function when the variables must satisfy a constraint.
Frequently Asked Questions
When should I use Lagrange multipliers instead of substitution?
If you can easily solve the constraint for one variable (like \(y = 4 – x\)), substitution turns the problem into a one-variable max/min problem. Lagrange multipliers are better when the constraint is a curve like a circle or ellipse, or when there are three variables.
Why does the calculator say some points are “neither”?
A candidate point can be a saddle along the constraint: \(f\) goes up in one direction and down in another. Those points satisfy the Lagrange equations but are not a max or a min.
How do I type the constraint?
Type it as an equation, like x^2 + y^2 = 8. If you leave out the “=”, the calculator treats it as “= 0”.
Is λ always positive?
No. Its sign depends on the direction of the gradients. A negative λ just means \(\nabla f\) points opposite to \(\nabla g\) at that point.
Related Calculators
- Partial derivative calculator
- Jacobian calculator
- Derivative calculator for one-variable max/min problems