Lagrange Multipliers Calculator
Enter the function and constraint.

Optimization with a Constraint

Lagrange multipliers provide a systematic way to find the local maxima and minima of a function subject to one or more equality constraints. Suppose we seek extrema of fx,y given the constraint gx,y=0. By introducing an auxiliary variable \lambda, we form the Lagrangian

Lx,y,\lambda=fx,y+\lambdagx,y

The method rests on the insight that at an extremum subject to the constraint, gradients of f and g are parallel. Setting the partial derivatives of L to zero yields the system

\nablafx,y=-\lambda\nablagx,y

combined with the original constraint gx,y=0. Solving these equations simultaneously pinpoints stationary points that may correspond to constrained maxima or minima.

Step-by-Step Procedure

In practice, we differentiate L with respect to x, y, and \lambda. Setting βˆ‚Lx=0, βˆ‚Ly=0, and βˆ‚L\lambda=0 yields three equations in the three unknowns. Solving this system gives candidate points. We then evaluate f at each candidate to determine which provide maxima or minima along the constraint curve.

Illustrative Example

Consider finding the extrema of fx,y=xy2 subject to gx,y=x+y-3. The Lagrangian is L=xy2+\lambdax+y-3. Taking partial derivatives gives

βˆ‚Lx=y2+\lambda

βˆ‚Ly=2xy+\lambda

βˆ‚L\lambda=x+y-3

Setting these to zero yields a system solvable for x, y, and \lambda. Substituting back into f reveals whether each solution is a maximum or minimum on the line x+y=3. This procedure generalizes easily to more variables and multiple constraints by adding one multiplier per constraint.

Why It Works

Geometrically, the gradient of f points in the direction of greatest increase, while the gradient of g is normal to the constraint curve. At a constrained extremum, movement along the constraint cannot increase or decrease f, meaning its gradient must be parallel to the gradient of g. The multiplier \lambda quantifies how strongly the constraint influences the optimum. This geometric viewpoint helps explain why the Lagrange multiplier technique is so widely used across calculus, physics, and economics.

Practical Usage

To apply the method with this calculator, enter any differentiable function f of two variables and a single constraint g. The tool relies on the symbolic differentiation capabilities of math.js to compute partial derivatives. After solving the resulting system numerically, the calculator displays the candidate points. You can then evaluate f at these points to determine maxima or minima.

Applications and Insight

Lagrange multipliers appear in diverse settings: optimizing production subject to resource limits, maximizing entropy with fixed energy, or finding shortest paths constrained to surfaces. The method links optimization to geometry, revealing how constraints shape feasible solutions. By experimenting with different functions and constraints, you will see how the multiplier value reflects the trade-off between satisfying the constraint and optimizing the objective.

This calculator aims to demystify the process by automating the tedious algebra. Understanding the underlying theory, however, remains essential for interpreting the results. With practice, you will recognize patternsβ€”for example, that equality constraints often represent level curves or surfaces along which we seek tangency with \nablaf. By mastering Lagrange multipliers, you gain a versatile tool for tackling constrained optimization problems in calculus, economics, and engineering.

Related Calculators

Dijkstra Shortest Path Calculator - Weighted Graph Solver

Find the shortest path between two nodes in a small graph using Dijkstra's algorithm.

dijkstra algorithm calculator shortest path

Cramer's Rule Solver - Solve 2x2 and 3x3 Systems

Use Cramer's rule to solve small linear systems with determinants.

Cramer's rule calculator linear system solver

Derivative Calculator - Find Instantaneous Rates of Change

Compute the derivative of a polynomial at any point to see how fast the function changes there.

derivative calculator polynomial derivative calculus tool