The Lagrange multiplier in this visualization
The problem is to find the largest or smallest value of a function when the point is not free but must stay on a curve, the constraint . The method of Lagrange multipliers says where to look. Suppose and have continuous first partial derivatives near a point P of the curve, restricted to the curve has a local maximum or minimum at P, and . Then there is a number , the Lagrange multiplier, with
These are three equations for x, y and . Their solutions are candidates, not answers: each one still has to be checked, and points where have to be looked at separately.
The map shows the contours of , the constraint curve in heavy ink, and a point P on it. At P the blue arrow is , the hollow arrow shows the direction of , and is split into a yellow part along the curve and a dashed part across it. Under the map, the profile plots against the distance walked along the curve.
Why does it work? Along the curve does not change, so the curve’s unit tangent is perpendicular to . Walking along the curve at unit speed, changes at the rate , which is the slope of the profile at P, and the yellow arrow is . At a highest or lowest point of the profile where , this slope is zero, so has no part along the curve. In the plane, a vector with no part along the curve is a multiple of , so , with if . Wherever the yellow arrow is not zero, walking the way it points still raises , so P cannot be a maximum or minimum there.
If also , the contour of through P is perpendicular to , so it has the same tangent as the constraint. At a constrained maximum or minimum the constraint touches a contour instead of crossing it.
has a meaning of its own. Write for the best value on the curve . If a point attaining this value moves smoothly as changes, then is the rate at which the best value changes:
On the circle the largest value of is , and at both maxima. The λ window plots against with this slope. The rate depends on how the constraint is written. Written as with , the same curve has half the multiplier, because it now measures change per unit of C. Write it as 2g shows this.
Two curves show the limits of the method. On , the function has parallel gradients at , yet along the curve only levels off there and keeps rising. Parallel gradients are not enough. On , the smallest value of is at the cusp , where and has no solution. The method misses it, so such points have to be checked by hand.
Whether a candidate is a maximum, a minimum or neither shows in the profile. It rises then falls at a local maximum on the curve, falls then rises at a local minimum, and at the cubic’s candidate it keeps rising.
Things to notice
- The sign of says whether points with or against it. On the circles it is positive at the maxima and negative at the minima.
- Touching a contour does not mean staying on one side of it. The cubic’s candidate touches a contour and still crosses it.