Worked examples — Lagrange multipliers for constrained optimization
This page is a catalogue of cases. The parent note showed you the machinery; here we run it on every kind of problem the topic can throw at you — different signs of , curved constraints, several constraints at once, degenerate cases where the method almost breaks, a word problem, and an exam-style twist.
Before we start, one tiny reminder of the only rule we use, spelled out in words:
Look at the figure: the grey curves are level curves of (points where has the same value, like contour lines on a map). The blue line is the constraint wall. At the star, a level curve just kisses the wall — they are tangent, so their perpendicular arrows line up. That tangency is the Lagrange condition.
The scenario matrix
Every Lagrange problem you will meet falls into one of these cells. The rest of the page fills each cell with a fully worked example.
| # | Case class | What makes it special | Example |
|---|---|---|---|
| A | Straight-line constraint, minimize | , convex, unique answer | Ex 1 |
| B | Symmetric objective, maximize | , symmetry shortcut | Ex 2 |
| C | Curved (nonlinear) constraint | changes direction; multiple candidates | Ex 3 |
| D | Negative multiplier | — relaxing the wall hurts | Ex 4 |
| E | Zero / degenerate | objective already flat, or | Ex 5 |
| F | Two constraints at once | vector , sum of gradients | Ex 6 |
| G | Word problem (real world) | translate words → ; read as price | Ex 7 |
| H | Exam twist | unknown constant ; solve for a target value | Ex 8 |
Ex 1 — Cell A: line constraint, minimize
Forecast: by symmetry between and , guess the answer sits at equal coordinates. Where?
- Build the Lagrangian. Why this step? It fuses objective and wall into one function whose flat points are the constrained optima.
- Differentiate in . Why? These say " is parallel to ."
- Differentiate in . Why? It returns the wall so we don't float off it.
- Solve. Why? Substitute : , so .
Verify: point lies on the line ( ✓). Distance. Since is a bowl (convex) and the wall a straight line, this single stationary point is the global minimum. : pushing the line out () raises the min distance by about .
The red arrow (pointing away from origin) and blue arrow point the same way at the star — that is why .
Ex 2 — Cell B: symmetric objective, maximize
Forecast: everyone "knows" the square wins — but why does the algebra force it?
- Lagrangian. .
- Partials in . Why? Parallel-gradient condition.
- Symmetry read-off. Why this step? The equations are identical after swapping , so the optimum must have — the symmetry of the problem is inherited by the answer.
- -partial + solve. , so .
Verify: area . Nudge perimeter to : new side , area , gain ✓. Units: has units of area per unit perimeter (m²/m = m), matching "shadow price."
Ex 3 — Cell C: curved constraint, multiple candidates
Forecast: a curved wall means points radially and keeps turning. So expect two answers — a max and a min on opposite sides.
- Lagrangian. .
- Partials. Why? Same rule, but now depends on position.
- Impose the circle. Why? Curved constraint, so substitute.
- Two branches. Why two? Each sign of is a genuine candidate.
- : , → maximum.
- : , → minimum.
Verify: both points satisfy ✓. At the max, points outward like (same direction, ); at the min the radial arrow points inward, opposite (). A curved wall must be checked at all candidates — this is the cell the line problems never showed.
Ex 4 — Cell D: negative multiplier
This is the minimizing half of Ex 3. We already found the candidate , , .
- Read the sign. Why this step? With , the optimal value changes by . Here .
- Interpret. Increase from to (bigger circle). Predicted change in min: , i.e. the minimum drops to about .
Verify (exact): on radius the minimum of is . At : . At : . Change ✓. Lesson of the cell: a negative is normal and meaningful — "relaxing the constraint" made the minimum smaller, not larger.
Ex 5 — Cell E: zero / degenerate inputs
Forecast: E1 has nothing to optimize; E2 has a constraint that is a single point.
E1 steps.
- Lagrangian. .
- Partials. , . Why ? Because : the objective doesn't change anywhere, so nudging the wall changes nothing — zero shadow price.
- Constraint. : every point on the line is an optimum.
Verify (E1): for all feasible points; there is no unique minimizer, and correctly reports "the wall's location is worthless to me." ✓
E2 steps.
- Inspect . forces — the constraint is a single point, not a curve.
- Check . at that point. Why does this break the method? Lagrange assumes so a well-defined perpendicular direction exists. Here there is no wall to be tangent to.
- Resolve by hand. The only feasible point is , so it is trivially both the max and min: .
Verify (E2): feasible set , ✓. Cell lesson: always confirm (a constraint qualification); when it fails, fall back to direct reasoning. This subtlety is exactly where KT Conditions add care for inequalities.
Ex 6 — Cell F: two constraints at once
Forecast: two walls → two multipliers → .
- Multi-constraint Lagrangian. Why a sum? Each wall pins one direction; must be a blend of both wall-arrows.
- Partials.
- Use symmetry . From , . Subtracting the first two partials: . Why? The two planes are already symmetric in , so the second wall costs nothing here.
- Solve. Then , . Plug into : , so .
Verify: ✓, ✓, . Any other point on the line has larger (convex bowl) ✓.
Ex 7 — Cell G: real-world word problem
Forecast: cost-minimizing under an area target — expect a square again, and to read as "metres of fence saved per extra m² required."
- Translate words → math. Objective = perimeter, wall = area. Why? Getting right is 90% of a word problem.
- Lagrangian. .
- Partials. , .
- Constraint + solve. , and .
Verify: area ✓, perimeter m. Units of : metres per m² = m; predicted extra fence for one more m² of area m. Exact: perimeter for area is , derivative ✓.
Ex 8 — Cell H: exam twist (solve for the constant)
Forecast: we solve the family in terms of , then invert.
- Solve generally. Why? Keep as a symbol so we can tune it. From Ex 1's pattern: , .
- Minimum value. .
- Set equal to target. .
- Interpret both roots. Why two? The line and are equidistant from the origin (symmetric across it), so both give min distance.
Verify: for : , ✓; , and ✓ (shadow price matches). For : , ✓.
Recall Quick self-test
Which sign does take when relaxing the wall improves a minimization? ::: Negative — a lower minimum means (see Ex 4). Why must a curved constraint be checked at every stationary candidate? ::: Because keeps rotating, giving several tangency points — some maxima, some minima (Ex 3). What breaks the whole method, and what do you do? ::: When (constraint qualification fails); solve the feasible set directly instead (Ex 5). In two constraints, what replaces ? ::: (Ex 6).
Where this goes next: equality-only Lagrange becomes the KKT system once you add inequality walls — see KT Conditions, and its starring role in Support Vector Machines, Regularization, Duality Theory, Convex Optimization, and the softer cousin Penalty Methods.