Lagrange Problem Solver Calculator

Enter objective and expressions using x and y. Choose maximize or minimize, run multi-start searches. Download clean reports for assignments, practice, and exam prep.

Input
Define your objective and constraint
Supported: + − * / ^ ( ) x y, sin cos tan, sqrt, log, exp
Use ^ for powers. Example: sin(x) + y^2
Put everything on one side. Example: x^2 + y^2 - 1
Helps find multiple stationary points.
Smaller is precise, but may be noisy.
Stops when KKT residual is below this.
Extra seeds besides your initial guess.
Random x,y vary by ±range.
Stores multiple candidate points.
Reset

Example data table

These sample inputs reproduce a classic constrained optimum.

Mode Objective f(x,y) Constraint g(x,y)=0 Expected best point
Minimize x^2 + y^2 x + y - 1 x=0.5, y=0.5
Maximize x*y x + y - 10 x=5, y=5
Minimize (x-2)^2 + (y+1)^2 x^2 + y^2 - 4 Closest point on circle

Formula used

The method builds a Lagrangian L(x,y,λ)=f(x,y)−λ·g(x,y) and solves the system: ∂L/∂x=0, ∂L/∂y=0, and g(x,y)=0. Derivatives are approximated by central differences, then Newton’s method refines (x,y,λ).

  • KKT stationarity: ∇f(x,y)=λ∇g(x,y)
  • Feasibility: g(x,y)=0
  • Residual: ||[∂L/∂x, ∂L/∂y, g]||

How to use this calculator

  1. Choose maximize or minimize.
  2. Enter f(x,y) and your constraint g(x,y)=0.
  3. Set an initial guess, then enable multi-start if needed.
  4. Press Solve to see results above this form.
  5. Download CSV or PDF from the result panel.

FAQs

1) What problems does this solver handle?

It solves two-variable optimization with one equality constraint. You can model many textbook Lagrange multiplier tasks using x and y expressions safely.

2) Why do I get no convergence sometimes?

Newton steps can fail near flat gradients or singular Jacobians. Try a different initial guess, increase the multi-start range, or relax tolerance slightly.

3) Does it guarantee a global optimum?

No. It finds stationary points that satisfy KKT conditions. Use multiple starts and compare objective values to increase confidence in the best solution.

4) What functions can I type?

Use + − * / ^, parentheses, x, y, and common functions like sin, cos, tan, sqrt, log, exp, abs. Unsupported tokens are blocked for safety.

5) How should I write the constraint?

Write it as a single expression equal to zero. Example: for x+y=10, enter x+y-10. For x²+y²=1, enter x^2+y^2-1.

6) What does the residual value mean?

Residual measures how closely the solution satisfies stationarity and feasibility. Smaller residual usually means a more accurate stationary point for your constraint.

7) How do I interpret multiple solutions?

Some problems have several stationary points. Sort by objective value for your mode, then validate with second-derivative reasoning or plotting if needed.

Related Calculators

euler equation solverelastic curve calculatorvariational inequality solvereuler lagrange equation calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.