Optimization and the Mean Value Theorem

The biggest box from a sheet of card, the fastest route to a swimmer, and the theorem that catches speeding drivers

Optimization and the Mean Value Theorem

At the top of a smooth hill the ground is level. That one observation, f′(x) = 0 at an interior maximum or minimum, turns “what is the best?” into an equation you can solve. Fold the biggest box, find the quickest way to a swimmer in trouble, then meet the theorem that guarantees an average speed was, at some instant, an actual speed.

Fold the Best Box

Cut a square from each corner of a sheet and fold up the sides. Scrub the cut and watch the volume rise and fall on the graph, then press find the best box to send the cut to the exact maximum.

1008
volume V(x), cm³
108
V′(x), cm³ per cm of cut
3.9237
best cut x*, cm
1056.3
largest volume, cm³
Cut x = 3 cm gives a 24 × 14 × 3 box holding 1008 cm³, 95.4% of the best.

Drag the 3D view to turn the box. The indigo block is the space the box holds. For a square sheet the best cut is exactly one sixth of the side, whatever its size; for a W × H sheet it is the smaller root of V′(x) = 12x² − 4(W + H)x + WH.

Go deeper:Setting Up and Solving an Optimization Problem

With squares of side x removed from a W × H sheet, the box has base (W − 2x) × (H − 2x) and height x, so

V(x) = x(W − 2x)(H − 2x), 0 ≤ x ≤ min(W, H)/2.

V is zero at both ends of that interval, so its maximum is inside, where the tangent is level. Expanding, V(x) = 4x³ − 2(W + H)x² + WHx and

V′(x) = 12x² − 4(W + H)x + WH = 0 ⇒ x* = [(W + H) − √(W² − WH + H²)] / 6.

The other root lies beyond min(W, H)/2, outside the sheet. For a square of side s the formula gives x* = s/6 and a largest volume of 2s³/27. A check with the second derivative, V″(x*) = 24x* − 4(W + H) < 0, confirms a maximum.

The pattern is always the same. Write the quantity to optimise as a function of one variable, using the constraints to eliminate the others; find where its derivative is zero or undefined; then compare those critical points with the endpoints. The extreme value theorem promises that a continuous function on a closed interval has a largest and a smallest value, so one of these candidates must win.

The Lifeguard’s Dilemma

Running is faster than swimming, so the straight line is not the quickest route. Drag the lifeguard, the swimmer and the entry point, change the two speeds, and race the routes against each other.

15.67 s
your time T(x)
11.73 s
quickest time
0.146
sin θ₁ / v₁ (θ₁ = 60.9°)
0.581
sin θ₂ / v₂ (θ₂ = 60.6°)
T′(x) = sin θ₁ / v₁ − sin θ₂ / v₂ = −0.435 s per metre. Negative: running a little further along the beach before entering would save time. You are 3.94 s slower than the best route.

Drag the lifeguard, the swimmer, or the white diamond on the shoreline (or drag along the lower graph). Angles are measured from the normal to the shore. Set both speeds equal and the quickest route becomes the straight line.

Go deeper:Snell’s Law from T′(x) = 0

Put the shoreline on the x-axis, the lifeguard at (g₁, −g₂) on the sand and the swimmer at (s₁, s₂) in the water. Entering at (x, 0) takes

T(x) = √((x − g₁)² + g₂²) / v₁ + √((s₁ − x)² + s₂²) / v₂.

Differentiating, each term gives a cosine of the path’s angle with the shore, which is the sine of its angle with the normal:

T′(x) = sin θ₁ / v₁ − sin θ₂ / v₂ = 0 ⇔ sin θ₁ / v₁ = sin θ₂ / v₂.

T is a sum of two convex functions, so this critical point is the one and only minimum. The equation is exactly the law of refraction for light passing from one medium to another, with v₁ and v₂ the speeds of light in each. Ibn Sahl described the law around 984; Willebrord Snellius found it again in 1621, and in 1662 Pierre de Fermat derived it from his principle that light takes the path of least time, the lifeguard’s principle.

In 2003 Timothy Pennings published “Do Dogs Know Calculus?” in The College Mathematics Journal. He threw a ball into Lake Michigan from the beach, timed his Welsh Corgi, Elvis, running and swimming, and found that the points where Elvis plunged in were remarkably close to the optimal entry points. Elvis, of course, was not differentiating anything; the calculus describes the behaviour, not the dog’s reasoning.

The Mean Value Theorem

Drag the endpoints a and b. The secant’s slope is the average rate of change, and every point c where the tangent runs parallel to it is found and marked. Try levelling the ends, and try the |x| preset, where the promise breaks.

[0.25, 2.2]
interval [a, b]
57.72
average speed, km/h
0.545, 1.55
c with f′(c) = secant slope
57.72
speedometer at c, km/h
Between t = 0.25 h and t = 2.2 h the car covered 112.6 km: an average of 57.72 km/h. The speedometer must have read exactly that at each of the 2 moments t = 0.5447, 1.55 h. If the average beats the limit, a toll road can issue a ticket without ever seeing the car speed.

Drag near either endpoint to move it. The points c are the zeros of f′(x) − m with f′(x) = 60 + 36cos(3x) found symbolically; violet rings mark corners or cusps where f′ does not exist.

Go deeper:Average Rates Are Achieved

Mean value theorem. If f is continuous on [a, b] and differentiable on (a, b), then for at least one c strictly between a and b,

f′(c) = (f(b) − f(a)) / (b − a).

Rolle’s theorem is the special case f(a) = f(b): somewhere in between, f′(c) = 0. Its proof is short. A continuous f on [a, b] attains a maximum and a minimum; if both are at the endpoints, f is constant and any c works; otherwise one of them is inside, where the tangent is level. The general theorem follows by applying Rolle to f minus its secant line, g(x) = f(x) − [f(a) + m(x − a)], which has g(a) = g(b) = 0.

Both hypotheses matter. For |x| on [−1, 2] the average slope is 1/3, but the derivative is −1 or +1 and never anything in between: the corner at 0 lets f′ jump over the value it needed. √x on [0, 4] shows the other side of the fine print: its derivative is infinite at 0, but only differentiability on the open interval is required, and c = 1 does the job.

The theorem is the bridge from local to global facts. It is why f′ = 0 everywhere forces f to be constant, why f′ > 0 makes f increasing, and why two antiderivatives of the same function differ by a constant. Average-speed enforcement relies on it too: if a car covers 30 km between two cameras in 15 minutes, its average speed is 120 km/h, so at some moment the speedometer read exactly 120. Michel Rolle published his theorem for polynomials in 1691; the general statement is usually credited to Lagrange, and Cauchy gave it a rigorous proof in the 1820s.

Key Takeaways

  • At an interior maximum or minimum of a differentiable function, f′(x) = 0: optimisation becomes equation solving.
  • Compare the critical points with the endpoints; a continuous function on a closed interval always has a best value.
  • Minimising travel time across two media gives sin θ₁ / v₁ = sin θ₂ / v₂, Snell’s law of refraction.
  • The mean value theorem: a smooth function’s average rate of change over [a, b] equals its instantaneous rate somewhere inside.

Spot a mistake or have an idea?

Search