Search numerically for regular local maximum or minimum candidates of f(x, y) subject to g(x, y) = c using Lagrange multipliers. The bounded search verifies stationarity and reports its limitations.
Related Calculators
- Z-Transform Calculator
- Picardโs Theorem Calculator
- Cardanoโs Formula Calculator
- Recursive Rule Calculator
- All Math and Numbers Calculators
Lagrange Multipliers Formula
For differentiable functions at a regular constrained local extremum, where the constraint gradient is nonzero, the method of Lagrange multipliers gives a necessary stationary condition. Introduce a multiplier lambda and set the gradient of f equal to lambda times the gradient of g.
\nabla f(x,y) = \lambda \, \nabla g(x,y)
This vector equation, written component by component and combined with the constraint, gives the system you solve.
f_x = \lambda \, g_x, \qquad f_y = \lambda \, g_y, \qquad g(x,y) = c
An equivalent route defines the Lagrangian function and sets each of its partial derivatives to zero.
L(x,y,\lambda) = f(x,y) - \lambda \, (g(x,y) - c)
Where:
- f(x, y) is the objective function you want to maximize or minimize.
- g(x, y) = c is the constraint that every valid solution must satisfy.
- f_x and f_y are the partial derivatives of f with respect to x and y.
- g_x and g_y are the partial derivatives of g with respect to x and y.
- lambda is the Lagrange multiplier, the scalar that links the two gradients at the optimal point.
Solutions of this system are stationary candidates, not automatic global optima. The calculator checks constraint and gradient residuals and uses the second derivative along the constraint tangent to classify numerical local maximum and minimum candidates. It selects the largest or smallest value among candidates matching your requested type. Global conclusions require separate analysis of all candidates, singular or domain-boundary points, and whether extrema exist.
Reference Solutions and the Meaning of Lambda
The first table lists common constrained problems with their known solutions, which you can use to check the calculator. The symbol ยฑ means both sign choices give a valid solution.
| Objective f(x, y) | Constraint | Solve for | Solution (x, y) | f | lambda |
|---|---|---|---|---|---|
| x*y | x + y = 10 | Maximum | (5, 5) | 25 | 5 |
| x^2 + y^2 | x + y = 1 | Minimum | (0.5, 0.5) | 0.5 | 1 |
| x^2 * y | x^2 + y^2 = 3 | Maximum | (ยฑ1.414, 1) | 2 | 1 |
| x^2 + y^2 | x * y = 1 | Minimum | (1, 1) and (-1, -1) | 2 | 2 |
Along a differentiable branch of regular constrained optima, with the sign convention L = f – lambda(g – c), lambda gives the first-order rate of change of that branch’s optimal value as c changes. This sensitivity interpretation needs those regularity assumptions; it does not establish a global optimum. The second table summarizes the sign under those assumptions.
| Value of lambda | Interpretation |
|---|---|
| lambda > 0 | Increasing c raises the optimal value of f. |
| lambda < 0 | Increasing c lowers the optimal value of f. |
| lambda = 0 | The first-order sensitivity along a regular optimal branch is zero. An equality constraint still applies; lambda = 0 does not mean that it is inactive. |
Example Problems
Example 1. You want the rectangle of largest area whose perimeter is 20. Let the side lengths be x and y, so the area is f(x, y) = x*y and the perimeter constraint is g(x, y) = 2*x + 2*y = 20. The gradient condition gives y = 2*lambda and x = 2*lambda, so x = y. Substituting into the constraint gives 4*x = 20, so x = 5 and y = 5. The maximum area is f = 25 with lambda = 2.5, which means each extra unit of perimeter adds about 2.5 units of area near this point.
Example 2. You want the point on the line x + y = 1 closest to the origin. Minimize f(x, y) = x^2 + y^2 subject to g(x, y) = x + y = 1. The conditions 2*x = lambda and 2*y = lambda force x = y, and the constraint then gives x = 0.5 and y = 0.5. The minimum squared distance is f = 0.5 with lambda = 1.
FAQ
What does the Lagrange multiplier lambda represent?
Lambda is the proportionality factor between the objective and constraint gradients at a regular stationary candidate. Along a differentiable branch of regular optima, it describes a small change in the branch value per change in c, using this page’s Lagrangian sign convention.
Why do I need to enter a constraint value c?
The method works on an equality constraint of the form g(x, y) = c. Entering c separately lets you keep the same constraint expression while testing different levels, such as x + y = 10 versus x + y = 12, without rewriting the function.
Does the calculator always find the global maximum or minimum?
No. It uses a deterministic 9 by 9 grid of starts within the selected search box and bounded damped Newton iterations. Accepted regular candidates must meet constraint and stationarity residual tolerances; local classification uses the tangent second derivative. The search can miss candidates, excludes singular and nondifferentiable points, and does not analyze domain boundaries or behavior at infinity. No matching candidate does not prove infeasibility or unboundedness. The search radius limits the numerical search rather than adding a mathematical constraint. Use the regular Lagrange conditions and separate analytic or certified methods when a global answer is needed.
