Optimization Problems

Here is a question worth millions of pounds a day. A drinks company sells a can that must hold exactly 330 ml. Aluminium costs money, and the company makes billions of cans — so what shape of can uses the least metal? Guessing won't do: shave half a square centimetre off every can and you've saved a fortune; get it wrong and a competitor undercuts you. Somebody has to calculate the best shape.

This is optimization — finding the best possible value of something — and it is, by a comfortable margin, the most-used piece of calculus in the real world. Your phone finds the fastest route to school. An airline loads the minimum fuel that safely makes the journey (every spare kilogram of fuel costs fuel to carry). A streaming service picks the video quality that maximises smoothness for your bandwidth. A factory schedules machines to minimise idle time; a farmer fences the biggest field; an engineer makes a bridge as light as possible without it falling down. Every engineering discipline, and most of economics, runs on this one move.

And it is one move. Strip away the story and every problem above asks the same thing: out of all the options allowed, which one makes some quantity as large (or as small) as possible? Calculus is built for exactly this, because the best value of a smooth function almost always sits at a local maximum or minimum — a place where the derivative is zero. Find where f'(x) = 0, check what kind of point you've found, and you have beaten every possible guess at once.

The ritual (it never changes)

Optimization problems arrive dressed up in stories — fences, boxes, ticket prices, cans — and the stories are what make people freeze. The cure is a fixed ritual: seven steps that convert any story into a one-variable calculus problem. Every worked example on this page follows it move for move.

  1. Draw a picture and name your variables. A labelled sketch does half the algebra for you.
  2. Write the quantity to optimize as a formula. It will usually contain two variables at first — that's normal.
  3. Write the constraint — the sentence in the problem that ties the variables together ("100 m of fence", "holds 330 ml", "cut from a 12 cm sheet").
  4. Substitute the constraint into the formula, so the quantity becomes a function of one variable — and state the domain: which values of that variable make physical sense.
  5. Differentiate and solve f'(x) = 0.
  6. Check what you've found: is it a maximum or a minimum (second derivative, or a sign table)? And compare it with the endpoints of the domain — on a closed interval the best value can sit on the boundary.
  7. Answer the actual question, in context, with units. If the question asked for the maximum area, the answer is an area — not the x where it happens.

Steps 5 and 6 are the calculus you already own from . Steps 1–4 are the new skill — modelling — and they are where all the marks are won and lost.

Worked example 1 — the fence against the river

A farmer has 100 m of fencing and a straight river. She wants a rectangular pen using the river as one side (no fence needed there). What is the largest area she can enclose?

Step 1 — draw and name. Sketch the river along the top, the pen hanging below it. Call the depth of the pen (the two sides running away from the river) x, and the far side, parallel to the river, w. Try it live below: drag the slider and watch a skinny deep pen, a wide shallow pen, and everything in between — same 100 m of fence each time, wildly different areas.

Step 2 — the quantity. Area: A = x \cdot w. Two variables, as promised.

Step 3 — the constraint. The fence covers two depths and one far side: 2x + w = 100, so w = 100 - 2x.

Step 4 — substitute, and state the domain.

A(x) = x(100 - 2x) = 100x - 2x^2, \qquad 0 < x < 50

(At x = 0 the pen has no depth; at x = 50 the two sides eat all the fence and the pen has no width. Either way, zero area.)

Step 5 — differentiate and solve. A'(x) = 100 - 4x = 0 gives x = 25.

Step 6 — check. A''(x) = -4 < 0 everywhere: concave down, so x = 25 is a genuine maximum — and both endpoints give area 0, so nothing on the boundary beats it.

Step 7 — answer the question. The pen should be 25 m deep and w = 100 - 50 = 50 m wide, enclosing

A(25) = 25 \times 50 = 1250 \text{ m}^2.

Notice the shape of the winner: the far side is exactly twice the depth. The free river side lets the rectangle stretch along the river — a fully fenced field would optimise to a square instead. Best shapes in these problems are almost always this kind of tidy, symmetric answer; a monstrous decimal is often a sign of an algebra slip.

Worked example 2 — the open-top box

Take a 12 \times 12 cm sheet of card. Cut a square of side x from each corner and fold up the flaps to make an open box. What cut gives the biggest volume? This one has a real trade-off: a bigger cut makes the box taller but its base smaller. Somewhere between "flat tray" and "tall chimney" is a sweet spot — and only calculus can say exactly where.

Steps 1–4. After the cuts, the base is (12 - 2x) on each side (a cut comes off both ends) and the folded height is x:

V(x) = x(12 - 2x)^2, \qquad 0 < x < 6

The domain matters: at x = 0 the box has no height, and at x = 6 the two cuts meet in the middle and there is no base left — the sheet has been entirely snipped away. Drag the slider: the shaded base shrinks as the corner cuts grow, and the volume curve below rises to a single peak, then collapses.

Solve it with calculus

Step 5 — differentiate and solve. Expand first — it makes the derivative painless:

V(x) = 144x - 48x^2 + 4x^3, \qquad V'(x) = 144 - 96x + 12x^2 = 12(x-2)(x-6)

Setting V'(x) = 0 gives x = 2 or x = 6. Now the domain earns its keep: x = 6 is the "no base left" endpoint, where the volume is zero — the mathematics is politely telling us that a flat, fully-snipped sheet is a critical point too (a minimum). Only x = 2 lies inside the allowed range.

Step 6 — check. V''(x) = -96 + 24x, so V''(2) = -48 < 0: concave down, a maximum.

Step 7 — answer the question. Cut 2 cm squares; the box is 8 \times 8 \times 2 cm and holds

V(2) = 2(12 - 4)^2 = 2 \cdot 64 = 128 \text{ cm}^3.

A pleasing pattern hides here: for any square sheet of side s, the same algebra gives a best cut of exactly s/6. Check it: 12/6 = 2. Solving one problem with letters instead of numbers solves the whole family at once — that is why engineers optimise formulas, not single cases.

Worked example 3 — pricing the gig

A venue charges £10 a ticket and sells 500 tickets. Market research says every £1 increase in the price loses 20 sales. What price maximises revenue? This is the same ritual wearing an economics costume — no geometry at all — and it exposes a lovely tension: raise the price and each ticket earns more, but fewer people come. Push too far and the room is empty.

Steps 1–4. Let p be the ticket price in pounds. A price of p is (p - 10) pounds above the current one, so sales are 500 - 20(p - 10) = 700 - 20p. Revenue is price times sales:

R(p) = p(700 - 20p) = 700p - 20p^2, \qquad 0 \le p \le 35

(At p = 35 the model says sales hit zero — nobody pays £35 for this band.)

Step 5 — differentiate and solve. R'(p) = 700 - 40p = 0 gives p = 17.5.

Step 6 — check. R''(p) = -40 < 0: a maximum. The endpoints back this up — R(0) = 0 (free tickets earn nothing) and R(35) = 0 (an empty room earns nothing).

Step 7 — answer the question. Charge £17.50. Sales drop to 700 - 350 = 350 tickets, but revenue climbs to

R(17.5) = 17.5 \times 350 = £6125,

up from £5000 at the old price — a 22.5% raise for changing one number on a poster. This is precisely how airlines, hotels and ticket sites set prices, just with bigger formulas and live data. Trace the curve below and notice how flat the top is: near the optimum, small pricing errors barely cost anything. That flatness is a general gift of maxima — the derivative is zero there, so the function hardly moves.

Nature was optimising long before calculus existed. Bees store honey in wax cells, wax is expensive to make (bees eat roughly eight grams of honey to produce one gram of wax), so the hive faces a textbook optimization problem: enclose a fixed area of cell using the least possible wall. The unbeatable single shape is the circle — of all shapes with a given perimeter, the circle encloses the most area. That fact is the famous isoperimetric problem, starring in legend when Queen Dido of Carthage, promised only as much land as one ox-hide could enclose, cut the hide into a single thin strip and swept out a huge (roughly circular) territory.

But circles don't tile — pack them together and wasteful gaps appear. Among shapes that tile the plane with no gaps, the regular hexagon has the least perimeter per cell. Mathematicians suspected this for two thousand years (Pappus of Alexandria argued it around 300 AD); it was finally proved — the "honeycomb conjecture" — by Thomas Hales in 1999. The bees had the answer first. Soap bubbles play the same game in 3D: a bubble pulls itself into a sphere because that is the least surface area enclosing its air.

And the 330 ml can from the top of the page? The ritual (with a cylinder's volume as the constraint) proves the least-metal can has its height equal to its diameter — a squat shape, noticeably shorter than the can in your hand. Real cans deviate because real engineering adds constraints calculus is then re-run with: thicker material in the lid, rims, stacking, and how the can feels in your grip. Amazon does the same dance, optimising its catalogue of box sizes against millions of past shipments, and airlines re-optimise fuel loads for every single flight. The stories change; the ritual doesn't.

Watch it on Khan Academy