Every optimum so far has been free to sit anywhere. What happens when the answer is required to lie exactly on some boundary — a fixed budget, a fixed total — and "downhill" would otherwise walk straight off of it?
The dashed line is a hard constraint: every point on it satisfies . The circles are level sets of — the smaller the circle, the smaller is there. Slide along the line and watch the circle passing through the point grow and shrink.
At the constrained optimum, the objective's level curve is exactly tangent to the constraint — their gradients point the same direction:
- — the objective being minimized (or maximized).
- — the equality constraint the solution must satisfy.
- — the Lagrange multiplier: the scalar that makes the two gradients equal.
- Why tangency is the condition
If the level curve crossed the constraint instead of touching it, you could slide a little further along the constraint and keep decreasing — so a crossing point can never be optimal. Only where the curve is tangent to the line is there nowhere better left to slide.
- Tangent curves share a normal direction
Two curves are tangent exactly when their gradients (normal directions) are parallel — which is what says algebraically.
- λ measures sensitivity to the constraint
isn't just bookkeeping: it says how much the optimal would change per unit of slack if the constraint (here, the "4") were relaxed.
f(x,y) = 16.00 — alignment error (∂f/∂x − ∂f/∂y) = -8.00
λ implied by x: 0.00, λ implied by y: 8.00
The accent arrow is at the current point; the dashed-line-colored arrow is the fixed direction of . Slide until they point the same way — that's the only spot on the whole line where they agree, and it's exactly where the level circle stops crossing the line and just touches it.
Minimize subject to :
- Write the Lagrange condition componentwise
and , so means and — which forces .
- Combine with the constraint
Substituting into gives , so and .
- Check a non-optimal point for contrast
At : . Matching components gives from but from — they disagree, so is not a critical point of the constrained problem, and indeed .
Slide the point along the constraint line until ∇f is parallel to ∇g — the accent arrow lines up with the dashed constraint arrow.
Constrained optimization doesn't abandon "follow the gradient" — it just adds one requirement: stay on the constraint, and stop only where the objective's gradient has nothing left to offer that the constraint would still allow. This exact condition, generalized to inequality constraints via the KKT conditions, is what SVMs solve to find their maximum-margin boundary.