31. Rolle's theorem and the Mean Value Theorem

📖 Reading · 16 min
💡 Every code box below is live — edit it and hit Run.

Almost everything you believe about derivatives — that a positive derivative means increasing, that a zero derivative means constant, that two functions with the same derivative differ by a constant — is a corollary of one theorem.

Here it is.

Rolle's theorem

If f is continuous on [a,b], differentiable on (a,b), and f(a) = f(b), then there is some c \in (a,b) with f'(c) = 0.

Start and end at the same height, and somewhere in between you must level off. Throw a ball and catch it at the same height: at the top, its vertical velocity is zero.

Proof. By the Extreme Value Theorem (§1.8), f attains a maximum and a minimum on [a,b].

Case 1: both occur at the endpoints. Since f(a) = f(b), the max and min are equal, so f is constant and f' = 0 everywhere in (a,b).

Case 2: an extremum occurs at an interior point c. At an interior maximum, the difference quotient \frac{f(c+h)-f(c)}{h} is \le 0 for h>0 and \ge 0 for h<0. Both one-sided limits equal f'(c), which forces f'(c) \le 0 and f'(c) \ge 0 simultaneously. Hence f'(c) = 0. \blacksquare

Note the EVT doing the work in the first line. Existence theorems compound.

The hypotheses are not decoration. f(x) = |x| on [-1,1] has f(-1)=f(1) but $f' $ is never zero — it fails differentiability at exactly one point, and that's enough.

The Mean Value Theorem

If f is continuous on [a,b] and differentiable on (a,b), then there is some c\in(a,b) with f'(c) = \frac{f(b)-f(a)}{b-a}

The instantaneous rate equals the average rate, somewhere. Drive 200 km in 2 hours and at some instant your speedometer read exactly 100 km/h — which is why average-speed cameras are legally sound.

Geometrically: some tangent is parallel to the chord from (a,f(a)) to (b,f(b)).

Proof. Rolle's theorem, applied to a function built for the purpose. Let

g(x) = f(x) - \left[f(a) + \frac{f(b)-f(a)}{b-a}(x-a)\right]

— that is, f minus the straight line through the endpoints, so g measures the gap between curve and chord. Then g(a) = g(b) = 0, and g inherits continuity and differentiability from f. Rolle gives a c with g'(c) = 0, i.e.

f'(c) - \frac{f(b)-f(a)}{b-a} = 0 \qquad\blacksquare

Tilting the picture until Rolle applies is the trick, and it's the same auxiliary-function move as §1.8's antipodal-temperature argument.

The consequences, which are the point

The MVT is rarely used to find c. It's used to prove the facts everyone uses daily.

1. Zero derivative means constant. If f' = 0 on an interval, then for any x_1 < x_2 the MVT gives f(x_2)-f(x_1) = f'(c)(x_2-x_1) = 0. So f is constant.

This is not obvious and it is not a definition — it is a theorem, and it needs the MVT.

2. Equal derivatives means differing by a constant. If f' = g', apply (1) to f - g. This is what licenses "+C" on every indefinite integral in §4. Without it, you'd have no idea whether antiderivatives came in a one-parameter family or something wilder.

3. Positive derivative means increasing. If f'>0 on an interval and x_1<x_2, then f(x_2)-f(x_1) = f'(c)(x_2-x_1) > 0.

Everything in §3.5 rests on this, and again: it's a theorem, not a definition. The derivative is a local quantity, and turning local information into a global statement about the whole interval is precisely what the MVT does.

4. Bounding a function from its derivative. If |f'| \le M then |f(b)-f(a)| \le M|b-a| — a Lipschitz bound, and the basis of most error estimates in numerical analysis.

The general shape: the MVT is the bridge from local to global. That's why it appears in the proof of the Fundamental Theorem of Calculus, of Taylor's theorem (§8.2), and of the error bounds for numerical integration (§4.11).

The Cauchy Mean Value Theorem

The generalisation that L'Hôpital's rule actually needs:

If f,g are continuous on [a,b] and differentiable on (a,b), there is a c with \left[f(b)-f(a)\right]g'(c) = \left[g(b)-g(a)\right]f'(c)

Taking g(x)=x recovers the ordinary MVT. When g' \neq 0 it rearranges to

\frac{f'(c)}{g'(c)} = \frac{f(b)-f(a)}{g(b)-g(a)}

which is exactly the "ratio of derivatives equals ratio of changes" statement L'Hôpital's rule turns into a limit. Same proof technique: apply Rolle to a cleverly chosen combination.

Doing it in Python

Finding the guaranteed c:

import sympy as sp

x, c = sp.symbols('x c')

problems = [
    ("x^2 on [1,3]", x**2, 1, 3),
    ("x^3 on [0,2]", x**3, 0, 2),
    ("sqrt(x) on [0,4]", sp.sqrt(x), 0, 4),
    ("sin(x) on [0,pi]", sp.sin(x), 0, sp.pi),
]

for name, f, a, b in problems:
    avg = sp.simplify((f.subs(x, b) - f.subs(x, a)) / (b - a))
    sols = sp.solve(sp.Eq(sp.diff(f, x).subs(x, c), avg), c)
    inside = [s for s in sols if s.is_real and a < s < b]
    print(f"{name:<20} average slope {str(avg):<10} c = {inside}")

The MVT as a speeding argument:

def position(t):
    """Someone's distance travelled, km, over 2 hours."""
    return 60*t + 20*t**2

total = position(2) - position(0)
print(f"distance covered in 2 hours : {total} km")
print(f"average speed               : {total/2} km/h")

# find where the instantaneous speed matches
def speed(t, h=1e-8):
    return (position(t + h) - position(t - h)) / (2*h)

lo, hi = 0.0, 2.0
for _ in range(60):
    mid = (lo + hi) / 2
    lo, hi = (mid, hi) if speed(mid) < total/2 else (lo, mid)

t = (lo + hi) / 2
print(f"\nspeedometer read exactly {total/2} km/h at t = {t:.6f} h")
print(f"check: speed there = {speed(t):.6f} km/h")

Consequence 2, which is where "+C" comes from:

from math import sin, cos

f = lambda x: sin(x)**2
g = lambda x: -cos(x)**2

def deriv(fn, x, h=1e-7):
    return (fn(x + h) - fn(x - h)) / (2*h)

print(f"{'x':>6} {'f-prime':>12} {'g-prime':>12} {'f - g':>10}")
for x in (0.0, 0.7, 1.5, 2.9, 4.4):
    print(f"{x:>6} {deriv(f,x):>12.8f} {deriv(g,x):>12.8f} {f(x)-g(x):>10.6f}")

print("\nidentical derivatives everywhere, and the difference is a constant (1).")
print("that is the MVT, and it is why indefinite integrals carry a +C.")

Rolle failing when a hypothesis is dropped:

def deriv(fn, x, h=1e-7):
    return (fn(x + h) - fn(x - h)) / (2*h)

print("f(x) = |x| on [-1, 1]:  f(-1) = f(1) = 1, so Rolle 'should' apply")
print(f"{'x':>8} {'f-prime':>12}")
for x in (-0.9, -0.5, -0.01, 0.01, 0.5, 0.9):
    print(f"{x:>8} {deriv(abs, x):>12.4f}")

print("\nthe derivative is -1 or +1 and never 0. the single point of")
print("non-differentiability at x=0 breaks the theorem completely.")

Worked example

Show that \sin is Lipschitz: |\sin b - \sin a| \le |b - a| for all a,b.

Apply the MVT to f(x) = \sin x on [a,b] (assume a<b; the other case is symmetric). Sine is continuous and differentiable everywhere, so there's a c with

\sin b - \sin a = \cos(c)\,(b-a)

Take absolute values, and use |\cos c|\le1:

|\sin b - \sin a| = |\cos c||b-a| \le |b-a| \qquad\blacksquare

What that buys you. Sine can never change faster than its input — it's a non-expansive map. Consequences:

  • |\sin x| \le |x| for all x (take a=0), which §1.4's squeeze needed.
  • Fixed-point iteration x_{n+1} = \sin(x_n) converges, because the map contracts distances.
  • Numerically, evaluating \sin never amplifies input error.

The general principle: a bound on |f'| becomes a bound on how fast f can change over any interval, however long. Local control becoming global control, which is the MVT's entire job.

Where it fails to apply: f(x) = x^2 has unbounded derivative, so no Lipschitz constant works globally — |f(b)-f(a)| can be arbitrarily larger than |b-a|. Restrict to a bounded interval and it comes back: on [-5,5], |f'|\le10, so f is Lipschitz with constant 10 there.

Your turn

1. Verify the MVT for f(x) = x^2 on [1,3] and find c.

2. Does Rolle's theorem apply to f(x) = 1 - x^{2/3} on [-1,1]?

3. Use the MVT to show e^x \ge 1 + x for all x \ge 0.

4. A car travels 150 km in 90 minutes. Prove it exceeded 95 km/h at some instant.

Solutions

1. f is a polynomial, so both hypotheses hold. Average rate:

\frac{f(3)-f(1)}{3-1} = \frac{9-1}{2} = 4

Set f'(c) = 2c = 4, giving \boxed{c = 2}, which is in (1,3) ✓.

For a parabola c is always the midpoint of the interval, since f' is linear and the average of a linear function over an interval is its value at the centre. Nice check to remember.

2. No. The function is continuous on [-1,1], and f(-1) = f(1) = 0 ✓. But

f'(x) = -\tfrac23 x^{-1/3}

is undefined at x = 0, which is inside (-1,1). Differentiability fails, so Rolle doesn't apply.

And indeed no c works: f' is never zero — it's negative for x>0 and positive for x<0, jumping between them without passing through 0. This is the cusp from §2.1, and it's a graph that clearly has a peak yet no horizontal tangent anywhere.

3. For x > 0 apply the MVT to f(t) = e^t on [0,x]: there's a c\in(0,x) with

e^x - e^0 = e^c(x - 0) \implies e^x - 1 = xe^c

Since c > 0, e^c > 1, and x > 0, we get xe^c > x, hence

e^x - 1 > x \implies e^x > 1+x

Equality holds at x=0, giving e^x \ge 1+x on [0,\infty) ✓.

(In fact e^x \ge 1+x holds for all real x, by the same argument on [x,0] for negative x. It's the statement that e^x lies above its tangent at 0 — the convexity fact from §3.1, and the foundation of every exponential bound in probability, including Chernoff bounds.)

4. 90 minutes is 1.5 hours, so the average speed was

\frac{150}{1.5} = 100 \text{ km/h}

Position s(t) is continuous and differentiable (a real car has a velocity at every instant), so the MVT gives a time c with

s'(c) = 100 \text{ km/h}

Since 100 > 95, the car was travelling above 95 km/h at that instant. \blacksquare

Note the argument gives more than asked: it doesn't just show the car exceeded 95, it shows it hit exactly 100. That's the MVT's characteristic strength — an exact equality, not an inequality — and it's exactly the reasoning behind average-speed enforcement.

Check yourself in code

Find the MVT's guaranteed point c for four functions.

For each, compute the average rate \frac{f(b)-f(a)}{b-a}, solve f'(c) = \text{that}, and print the solution lying in (a,b) — exact form, plus 6 decimals.

Print exactly this:

x^2 on [1,3]       avg slope 4  c = 2  (2.000000)
x^3 on [0,2]       avg slope 4  c = 2*sqrt(3)/3  (1.154701)
sqrt(x) on [0,4]   avg slope 1/2  c = 1  (1.000000)
1/x on [1,4]       avg slope -1/4  c = 2  (2.000000)
import sympy as sp

x, c = sp.symbols('x c')

problems = [
    ("x^2 on [1,3]", x**2, 1, 3),
    ("x^3 on [0,2]", x**3, 0, 2),
    ("sqrt(x) on [0,4]", sp.sqrt(x), 0, 4),
    ("1/x on [1,4]", 1/x, 1, 4),
]

for name, f, a, b in problems:
    avg = (f.subs(x, b) - f.subs(x, a)) / (b - a)
    # solve f'(c) = avg and keep the root strictly between a and b
    print(f"{name:<18} avg slope {avg}  c = ...")
import sympy as sp

x, c = sp.symbols('x c')

problems = [
    ("x^2 on [1,3]", x**2, 1, 3),
    ("x^3 on [0,2]", x**3, 0, 2),
    ("sqrt(x) on [0,4]", sp.sqrt(x), 0, 4),
    ("1/x on [1,4]", 1/x, 1, 4),
]

for name, f, a, b in problems:
    avg = (f.subs(x, b) - f.subs(x, a)) / (b - a)
    sols = sp.solve(sp.Eq(sp.diff(f, x).subs(x, c), avg), c)
    inside = [s for s in sols if s.is_real and a < s < b]
    print(f"{name:<18} avg slope {avg}  c = {inside[0]}  ({float(inside[0]):.6f})")

Rolle says equal endpoint values force a horizontal tangent somewhere; the MVT tilts that picture and says some tangent is parallel to the chord. The MVT is almost never used to find c — it's used to prove that zero derivative means constant, equal derivatives mean differing by a constant (the source of "+C"), positive derivative means increasing, and bounded derivative means Lipschitz. Every one of those converts local derivative information into a global statement, which is what the theorem is for.

Next: cashing those consequences in — reading a function's entire shape off the signs of f' and f''.