Worked examples — Optimization — constrained, unconstrained, real-world problems
The scenario matrix
Every optimization problem lives in one of these cells. We will solve at least one example in each row.
| Cell | What makes it special | Where the answer lives | Example |
|---|---|---|---|
| A. Interior max | smooth hilltop, | a critical point inside | Ex 1 |
| B. Interior min | smooth valley, | a critical point inside | Ex 2 |
| C. Endpoint wins | derivative never zero, or critical point loses | boundary of domain | Ex 3 |
| D. Degenerate / | second-derivative test is blind | need first-derivative sign test | Ex 4 |
| E. Constrained (substitution) | one variable killed by a side relation | interior of reduced problem | Ex 5 |
| F. Constrained (Lagrange) | keep both variables, use | tangency point | Ex 6 |
| G. Real-world word problem | translate prose → symbols → derivative | wherever the recipe lands | Ex 7 |
| H. Exam twist (hidden domain / units) | the "obvious" root is illegal or the wrong thing is optimized | after a domain / units check | Ex 8 |
Before any symbol appears, one convention.
Cell A — Interior maximum
Forecast: guess the shape of the biggest rectangle before reading on. (Square? Long thin strip?)

- Name & model. Let the sides be and (metres). Area . Why this step? We must write the thing we optimize in symbols before we can differentiate it.
- Constrain to one variable. The fence is the perimeter: . Why this step? has two unknowns; a 1-D derivative needs one. The perimeter relation lets us eliminate .
- Reduce. , with domain (a side can't be negative, and leaves nothing for ). Why this step? Now is a plain parabola in one variable — look at the red curve in the figure, an upside-down bowl.
- Kill the derivative. . Why this step? At the top of the ∩-shaped area curve the slope is flat, so we set the slope to zero.
- Classify. → cap-shaped → local maximum by the second-derivative test. Why this step? A zero slope alone could be a hilltop, a dip, or an inflection; the negative curvature confirms hilltop.
- Answer. , , area . The optimal pen is a square.
Cell B — Interior minimum
Forecast: will the cheapest can be tall and thin, short and fat, or something in between?
- Model. Surface area of a closed cylinder: (two circular lids plus the wall). Why this step? Metal used = total surface area; that is the quantity to minimize.
- Constrain. Volume fixes height: . Why this step? Two unknowns ; the volume condition removes .
- Reduce. , domain . Why this step? Now depends on alone. As the term blows up; as the term blows up — so a minimum must sit in the middle.
- Kill the derivative. . So . Why this step? At the bottom of the ∪-shaped cost curve the slope is flat.
- Classify. for all → cup → minimum. Why this step? Confirms valley, not a peak.
- Answer. , — note : the optimal can is exactly as tall as it is wide.
Cell C — The endpoint wins
Forecast: where's the smallest value — inside, or at one edge?

- Differentiate. . Why this step? We look for flat spots first.
- Set . has no solution — is always positive, so everywhere. Why this step? No interior critical point exists; the slope is always downhill (see the strictly falling red curve).
- Fall back to the Closed Interval Method. With no interior candidate, the extremes must be the two endpoints. Evaluate: (the maximum), (the minimum). Why this step? A continuous function on a closed interval always attains its extremes; if not inside, they're on the wall.
- Answer. Minimum value at ; maximum at .
Cell D — Second-derivative test fails ()
Forecast: is a min, a max, or neither?
- Find critical points. . Why this step? Flat-spot hunt.
- Try the second-derivative test. , so — inconclusive. Why this step? The parent's Taylor argument used ; if that term vanishes and can't tell us the sign of the change.
- Use the first-derivative sign test instead. Check the sign of on each side:
- For : (downhill).
- For : (uphill). Why this step? Down-then-up around a point is precisely the fingerprint of a valley — no curvature number needed.
- Answer. Slope goes then ⇒ local (and global) minimum at .
Cell E — Constrained by substitution
Forecast: is the closest point the vertex , or does it slide off to the side?

The picture sets the scene: the black parabola , the red target dot at , and the red segment we will minimize dropping straight down to the vertex. Keep an eye on that segment — the algebra below will prove it is the shortest one.
- Model the distance — but square it. Distance from a general point on the parabola to : Why square it? is increasing, so whatever minimizes also minimizes the true distance — and the algebra stays polynomial (parent's trick, cell reused here).
- Substitute the constraint. We already used to write in one variable — that is the substitution route. The domain is all real : the parabola stretches infinitely both ways, so there are no endpoints to worry about. Why this step? Turns a "point on a curve" problem into ordinary 1-D optimization, and fixes exactly which -values compete.
- Expand & differentiate. . Why this step? Flat-spot hunt on the reduced function. (Notice the neat cancellation of the terms.)
- Rule out "at infinity." Since and as , the distance grows without bound far from the vertex — so no better point hides out at the tails. The single interior critical point is therefore the global minimum. Why this step? On an unbounded domain there are no endpoints; we must instead check the limiting behaviour to be sure the minimum is genuinely global.
- Classify. Around , goes (same cell-D reasoning, since ): down then up, a valley. Why this step? Confirms this is the nearest, not farthest, point.
- Answer. Nearest point is the vertex , at distance — exactly the red vertical segment in the figure.
Cell F — Constrained by Lagrange multipliers
Forecast: which direction on the unit circle points "most north-east"?

- Set up the gradients. With : Why this step? At a constrained optimum, must be perpendicular to the constraint curve — i.e. parallel to (see the Lagrange condition). The red arrow points north-east; the optimum is where it lines up with the outward radius.
- Write . Component by component: Why this step? Parallel vectors are scalar multiples; is that scalar.
- Solve. Both equations give , so . Why this step? Equal partials of force equal coordinates here.
- Apply the constraint. with gives . Why this step? We must land on the circle, not just satisfy the tangency.
- Evaluate & answer.
- : → maximum.
- : → minimum.
Cell G — Real-world word problem
Forecast: does she head straight for the swimmer, or aim further down the beach to spend more time on the fast sand?

- Model total time. Run distance (along the beach), swim distance . Why time, not distance? The two legs have different speeds, so time is the honest quantity to minimize (this is exactly Snell's-law / Fermat's-principle logic).
- Differentiate. Using the chain rule on the square root: Why chain rule? The swim distance is a function inside a square root; the chain rule handles "function of a function."
- Set . Let : Why this step? A flat spot marks the fastest path; setting and clearing fractions isolates the geometry. The substitution just tidies the algebra — it names the horizontal swim distance.
- Square carefully. Squaring is only valid when the right side is non-negative, i.e. ; we keep that restriction and will discard any root with as extraneous. Squaring: . The negative root is extraneous (it fails ), so . Why this step? Squaring can invent false solutions; the gate and a sign check remove them.
- Back-substitute. m. Why this step? We solved for ; the question asks for the shore point .
- Classify / check endpoints. s, s, and s — the interior point beats both edges, so it is the minimum. Why this step? Fermat gives only a candidate; comparing endpoints proves it's the global best on .
Cell H — Exam twist (illegal root / wrong objective)
Forecast: guess whether the field is wider along the river or perpendicular to it.
- Model & constrain. Fence length (two ends of length , one far side of length ). Area: . Why this step? Only three sides are fenced — reading the geometry correctly is half the exam battle.
- Reduce. , domain . Why this step? One variable, ready to differentiate.
- Kill the derivative. . Why factor out the sign? Two algebraic roots appear: and .
- The twist — reject the illegal root. A fence length can't be negative, so is outside the domain ; discard it. Only survives. Why this step? This is the classic exam trap: a genuine root of that is physically impossible.
- Classify & answer. at → minimum. Then , and m. Why this step? Positive curvature confirms the valley; report the actual fence length with units.
Recall Which cell am I in? (self-quiz)
Function is strictly increasing on — where's the max? ::: At the right endpoint (Cell C). and — next tool? ::: First-derivative sign test (Cell D). Two variables tied by one equation, want to eliminate one — which method? ::: Substitution (Cell E). Two variables, constraint hard to solve explicitly — which method? ::: Lagrange multipliers, (Cell F). Got for a length — what do you do? ::: Reject it; it's outside the physical domain (Cell H). Optimizing time across two speeds — minimize distance or time? ::: Time, since speeds differ (Cell G).
Connections
- Optimization — constrained, unconstrained, real-world problems — the parent recipe these examples drill.
- Critical Points & Fermat's Theorem — why we hunt first.
- Second Derivative & Concavity — the ∪/∩ classification in Cells A, B, H.
- Closed Interval Method (Global Extrema) — decides Cells C and G.
- Taylor Series Expansion — explains why is silent (Cell D).
- Lagrange Multipliers (Multivariable) — the tangency method of Cell F.
- AM-GM Inequality — the "equal is best" moral of Cell A.
- Related Rates — sibling skill of turning prose into derivative equations.