Calculus
Lagrange Multipliers
Stand the objective up as a hill and the constraint becomes a fence winding across it. Walk the fence to its highest point: there the ground is tangent to a contour line, which is exactly the statement that the two gradients line up.
the fence, f along the constraint∇f∇gthe ball, a peak on the fence
Drag to orbit · scroll to zoom · the dashed line is the contour through the ball · Walk uphill climbs the fence until the slope along it is zero
Slope along the fence—
—
Objective f(x, y)
Values
height f here—
∠(∇f, ∇g)—
multiplier λ here—
best height f* on this circle—
df* / d(r²)—
What to observe
- Press Walk uphill: the ball climbs the fence and stops where the slope along it is zero. There the dashed contour through the ball just touches the fence.
- At the top ∇f and ∇g are 0° apart, so ∇f = λ∇g. Away from the peaks and dips they disagree and there is still uphill left.
- Change the radius r and the best height changes with it. At the top, λ equals df*/d(r²): the multiplier is the price of loosening the constraint.
- On x · y the fence has two peaks and two dips. Walking uphill finds the peak on your side, not always the same one.
Shortcuts:space animate · f fullscreen