Back

Lagrange Multipliers

To find the largest or smallest value of $f(x,y)$ while staying on a constraint curve $g(x,y) = c$, walk along the curve and watch $f$ rise and fall. At the very top or bottom your motion is momentarily level, which means $f$ is not changing as you slide along the constraint: the gradient of $f$ has no component along the curve, so it must point straight across it, parallel to the gradient of $g$. That is the Lagrange condition, $\nabla f = \lambda\,\nabla g$. Geometrically the constraint curve just kisses a level set of $f$ at the optimum, touching it tangentially rather than crossing it. Sweep the point around the constraint and watch the two gradient arrows swing relative to each other; the green markers are the spots where they line up, and they are exactly the peaks and valleys of $f$ measured along the curve in the plot below.

Figure 1. Lagrange multipliers. Top: the contours of f with the constraint curve, a sweeping point and the gradients of f (gold) and g (blue); the green markers are the constrained optima, where the constraint is tangent to a level set and the gradients align. Bottom: f measured along the constraint, whose peaks and valleys are those optima. Method: closed-form objectives with exact gradients. Source: Stewart, Calculus, 8e, Sec. 14.8.
problem
position12 %

WHAT TO TRY

  • Let it sweep and watch the gold and blue gradient arrows swing: they line up only at the green markers, the constrained optima.
  • At an optimum the constraint just grazes a contour line (tangent, not crossing); away from it the constraint cuts across the contours.
  • Read the lower plot: the green markers sit exactly at the peaks and valleys of f measured along the constraint.
  • Switch problems: maximising x + y on a circle gives the 45 degree point (value sqrt(2)); the distance problem finds the nearest and farthest points of the ellipse.