Lagrange Multipliers Calculator
Type a function and a constraint to find its largest and smallest values on it.
The function f whose largest and smallest values you want, in x, y (and z).
The left side g(x, y) of the constraint, with its constant in the next box.
The number the constraint equals, such as 10.
Optional: a second constraint, which needs all three variables. Leave empty for one constraint.
Optional: the number the second constraint equals.
Result
You entered
The system was solved numerically from many starting points, so a solution very far from the origin could be missing.
Candidate (minimum)
Candidate (maximum)
Show the work
Lagrange condition
At an extreme value of on the constraint, the gradient of is a multiple of the gradient of the constraint (a combination of them), because moving along the constraint does not change to first order there.
Using
System of equations
Together with the constraint this gives 3 equations in 3 unknowns.
Solve the system
Solving the equations (numerically from many starting points, each solution checked in every equation, and written exactly when it is) gives 2 candidate points.
Value of f at each candidate
Substitute every candidate into f. Walking a short way along the constraint from each one shows whether f rises, falls or does both.
Result
The largest and smallest values among the candidates that are extremes along the constraint.