Visual walkthrough — Lagrange multipliers for constrained optimization
This page unfolds the central result of Lagrange multipliers as a sequence of pictures. Read it in order — each step's figure is the argument.
Step 1 — What "optimize" even means, drawn as a landscape
WHAT. We have a function . Think of it as the height of a hill above every point on a flat map. Feeding in a location returns an altitude.
WHY a hill? Because "maximize " then literally means "find the highest ground," and "minimize " means "find the lowest valley." Turning numbers into height lets your eyes do the optimizing.
PICTURE. In the figure, the map is the floor; the coloured curves are contour lines — each curve joins points of equal height, exactly like a topographic map. Close-together contours mean a steep slope; far-apart contours mean gentle ground.

Symbol check, term by term in :
- :: the height machine, "how high am I at this spot."
- :: the one altitude we froze to draw a single curve.
Step 2 — The constraint is a fence you must walk on
WHAT. Now add . This is a second landscape , but we only care about one of its contours — the one at height . That single curve is drawn on our map as a path. You are only allowed to stand on this path.
WHY. Real problems forbid free roaming: a fixed budget, a fixed perimeter, a required margin. The equation is the mathematical fence. Points off the fence are infeasible — they don't exist for us.
PICTURE. The amber curve is the constraint path . The greyed-out region is forbidden. Optimizing now means: walk along the amber path only, and find the highest (or lowest) contour of you touch.

Term by term in :
- :: a second height machine (budget used, perimeter length, ...).
- :: the fixed level we are locked onto — the fence's exact altitude.
Step 3 — The gradient: the arrow of steepest uphill
WHAT. We introduce a tool: the gradient . At any point it is an arrow that points in the direction of fastest increase of , and whose length says how fast.
WHY this tool and not another? We need to know, at a candidate point, "which way is uphill for , and which way is uphill for the fence ?" The gradient is the exact object that answers "which direction increases this function fastest." No other single object packages direction-of-increase this cleanly.
PICTURE. The cyan arrow is . Notice a crucial fact drawn in the figure: the gradient is always perpendicular to the contour line through that point. Uphill is the shortest way to the next contour, and the shortest way to a curve is straight across it.

Same story for the fence: is an arrow perpendicular to the amber path.
Step 4 — Walking the fence and asking "am I still improving?"
WHAT. Stand on the fence and take a tiny legal step that keeps you on the amber path. How much does change? The answer is the dot product .
WHY the dot product? Because we need to know how much of the uphill arrow lies along the direction we actually walk. The dot product is precisely "how much of points the same way as " — it is the change in for that step. That is the exact question here, so that is the tool.
PICTURE. The figure shows the legal step (tangent to the fence, in white) and the uphill arrow (cyan). Their dot product is the projection of one onto the other.

Two legal steps in a plane point and . One of them decreases unless . So the optimum demands:
Step 5 — Legal steps are exactly the ones perpendicular to
WHAT. Which steps keep us on the fence? A step that stays on must not change , so . Thus legal steps are precisely those perpendicular to .
WHY. points straight across the fence (Step 3). Anything perpendicular to it runs along the fence — that is the only way to move without leaving .
PICTURE. The white tangent step is at a right angle to the amber gradient . Every allowed direction lives on this tangent line.

So we now have two facts at the optimum, for every legal :
Step 6 — Two arrows perpendicular to the same line must be parallel
WHAT. Both and are perpendicular to the same tangent line (the set of legal steps). In a 2D plane there is only one direction perpendicular to a given line. So and must point along the same line — they are parallel.
WHY. This is the whole mechanism. If had any sideways component along the fence, that component would be a legal uphill direction, and we could improve — contradiction. Killing the sideways component forces to lie entirely across the fence, exactly where already lies.
PICTURE. At the optimum the cyan arrow and the amber arrow lie on one line — the contour of kisses (is tangent to) the fence. Away from the optimum they point in noticeably different directions and the contour crosses the fence.

Because they are parallel, one is a scalar multiple of the other:
Term by term:
- :: the optimal spot on the fence.
- :: uphill arrow of the objective there.
- :: across-fence arrow of the constraint there.
- :: the stretch factor that makes the two arrows match — the Lagrange multiplier. Its sign says whether they point the same or opposite way; its size says how many -arrows fit in one -arrow.
Step 7 — Degenerate cases you must not skip
WHAT / WHY / PICTURE — three failure modes, each drawn.
-
. The arrows still align, but by itself. The optimum happens to sit at a flat spot of that also lies on the fence — the constraint is not "pushing." Interpretation: relaxing the fence would not change the optimal value.
-
at the point. The fence has a cusp or singular point — no well-defined across-fence direction, so "parallel to " is meaningless. The method can silently miss such points; they must be checked by hand.
-
Tangency but a maximum vs minimum. Alignment () is necessary but does not tell max from min. Two points on a closed loop fence can both satisfy it — one highest, one lowest. You still compare values.

The one-picture summary
Everything above collapses into a single frame: the fence in amber, the family of -contours in cyan, and the unique spot where a contour is tangent to the fence — where the two gradient arrows share a line. That tangency is .

Recall Feynman retelling — say it in plain words
Picture a hill and a footpath painted across it. You're only allowed to walk the path. You wander looking for the lowest point on the path. At the true lowest point, the path can't be heading downhill or uphill anymore — if it did, you'd keep walking. So right there the ground's steepest-downhill arrow points straight off the side of the path, not along it. The path's own "which-way-is-across" arrow also points straight off the side. Two arrows pointing off the same side of the same path must point along the same line. Write "objective's uphill arrow equals some number times the path's across arrow," and that number — how much you stretch one arrow to get the other — is . It even tells you a bonus: how much better your best value would get if you shoved the path a little. The only traps: sometimes is zero (the path wasn't really squeezing you), sometimes the path has a sharp corner with no clean across-direction, and always remember the highest and lowest points both pass this test — so compare heights at the end.
Recall Quick self-test
Why must be perpendicular to the constraint at the optimum? ::: Any component of along the fence would be a legal uphill direction, so you could improve — contradiction with being optimal. What does signify geometrically? ::: The optimum is a flat spot of itself; the constraint isn't binding, and relaxing doesn't change the optimal value. Does tell you max from min? ::: No — it flags all tangency candidates; you still compare values and check singular points.
Connected ideas: the "no downhill along the fence" logic generalises to inequalities in KT Conditions; the multipliers reappear as the dual variables in Duality Theory and as the of Support Vector Machines; the same tangency picture underlies the shrinkage geometry of Regularization and the smooth-fence trick of Penalty Methods; when the objective is bowl-shaped the tangency point is the global optimum, studied in Convex Optimization; and following directly is the topic of Gradient Descent.