Lagrange Multipliers
Lagrange Multiplier Graphs
Draw the objective surface, the constraint, and the stationary candidates. The unit circle has global maximum 1/2 and global minimum -1/2. The distance problem has global minimum 50 and no global maximum. The product has global maximum 25 and no global minimum. In three variables, 64 is a local maximum, not a global maximum.
Generate Graph draws lagrange(x*y,x^2+y^2-1,x,y) in the existing 3D viewer. The height field is z = x*y. The unit circle is drawn in the xy-plane and again lifted onto the surface. Amber marks show the global maximum 1/2 and teal marks show the global minimum -1/2. Labels display those objective values. Orbit, zoom, pan, and the existing surface export stay on this viewer.
The same viewer draws lagrange(x^2+y^2,x+y-10,x,y), whose lifted line reaches the global minimum 50 at (5, 5), and lagrange(x*y,x+y-10,x,y), whose lifted line reaches the global maximum 25 at (5, 5). For lagrange(x*y*z,x+y+z-12,x,y,z) the constraint is the plane x+y+z = 12, with a marker at (4, 4, 4) labeled 64. That point is a local maximum, not a global maximum, and saddle markers at the three intercepts are labeled 0. The export is the surface mesh. Overlay curves and labels stay in the viewer.
Equation
lagrange(x*y,x^2+y^2-1,x,y)
When a Lagrange candidate is an optimum
Lagrange multipliers locate stationary candidates of an objective f subject to one equality constraint g = 0. The condition is ∇f = λ∇g together with g = 0. DGS forms those equations from the existing symbolic derivative, solves them with the existing symbolic solver, and keeps exact real solutions. A point is kept only after it satisfies the constraint. A point where the gradient of g is zero is degenerate: the multiplier theorem does not apply there, and that point is not forced through the regular system.
A stationary candidate is not automatically a maximum or a minimum. The second-derivative test on the tangent plane classifies a regular point as a local maximum, a local minimum, a saddle, or inconclusive. A global claim is added only when a separate argument proves it, such as a compact constraint with a complete stationary list, a constant objective, a finite feasible set, or a one-variable reduction of an affine constraint. When the objective is unbounded on the constraint, the result says which side has no global extreme. When that proof is missing, the classification stays inconclusive.
Reading the input
lagrange(x*y,x^2+y^2-1,x,y)— This is a command. The name selects the routine, and the items inside the parentheses are its arguments.
Other versions of this example
These stay on this page so each version keeps the same explanation. Choose Try example to run a version in its Studio workflow, or copy it into the editable field below.
Circle constraint
Global maximum 1/2 and global minimum -1/2 on the unit circle.
lagrange(x*y,x^2+y^2-1,x,y)
Minimum distance
Global minimum 50 at (5, 5). There is no global maximum.
lagrange(x^2+y^2,x+y-10,x,y)
Product optimization
Global maximum 25 at (5, 5). There is no global minimum.
lagrange(x*y,x+y-10,x,y)
Three variables
(4, 4, 4) has value 64 and is a local maximum, not a global maximum. The other stationary candidates are saddles. The objective is unbounded above and below.
lagrange(x*y*z,x+y+z-12,x,y,z)
Try a change
- Change the unit-circle objective from x*y to x^2+y^2 and generate again. The objective equals 1 at every feasible point, so that constant is both the maximum and the minimum.
- For the three-variable product, compare 64 at (4, 4, 4) with the feasible point (24, -6, -6). The product 864 is larger, so 64 is only a local maximum.
Generate Graph uses the existing 3D viewer. A two-variable problem draws the objective surface, the constraint curve in the xy-plane, the same curve lifted onto the surface, and labeled stationary candidates. A three-variable problem draws the constraint surface and the stationary points. Orbit, zoom, pan, and export stay on that viewer. The exported file is the surface mesh.