---
title: The derivative and the mean value theorem
heading: Somewhere, the instantaneous rate equals the average rate
eyebrow: A14 · Lesson 15 · The derivative and the mean value theorem
xp: 40
---

::: hook
If you drive 100 km in an hour, at some instant your speedometer read exactly 100 km/h. That everyday fact is the **mean value theorem**, and it's the bridge between a function's derivative and its actual changes. It's what turns a bound on the slope into a bound on the error: if a sensor's response never has slope steeper than L, an input uncertainty of Δ can never cause an output change bigger than LΔ. Every error estimate in A13 that mentioned $\max\lvert f''\rvert$ came from this theorem or its extension, Taylor's theorem.
:::

::: play
- The curve is $x^3$ on [a, b]. The dashed line is the secant from (a, a³) to (b, b³); its slope is the average rate of change.
- The mean value theorem promises a point c between a and b where the tangent is parallel to the secant. For $x^3$ it's $c = \sqrt{(a^2 + ab + b^2)/3}$ (marked).
- Move a and b: c always stays inside the interval, though usually not at the middle.
:::
:::

```sim plot
view: graph
x: x = -0.5..2.5
y: y = -1..12
slider: a = 0..1.2 step 0.05 = 0.2
slider: b = 1.3..2.2 step 0.05 = 2
plot: x^3 | label: x³
plot: a^3 + (b^3 - a^3)/(b - a)*(x - a) | dashed | label: secant
plot: (sqrt((a^2 + a*b + b^2)/3))^3 + 3*(a^2 + a*b + b^2)/3*(x - sqrt((a^2 + a*b + b^2)/3)) | dashed | color: ch3 | label: tangent at c
marker: x = sqrt((a^2 + a*b + b^2)/3) | label: c
readout: secant slope = (b^3 - a^3)/(b - a)
readout: c = sqrt((a^2 + a*b + b^2)/3)
```

::: predict
## A sensor's output y = f(x) has $\lvert f'(x)\rvert \le 4$ everywhere. If x is known to within 0.01, how far off can y be?

- [ ] 0.01
- [x] At most 0.04
- [ ] 0.0025
- [ ] It can't be bounded without f

::: reveal
At most 0.04: by the mean value theorem $f(x + \Delta) - f(x) = f'(c)\Delta$ for some c between, and $\lvert f'(c)\rvert \le 4$. The theorem needs no formula for f, only a bound on its slope.
:::
:::

::: nameit
## The derivative

$$f'(a) = \lim_{h\to 0}\frac{f(a + h) - f(a)}{h}$$

when the limit exists. Differentiable implies continuous (the numerator must tend to 0); the reverse fails, as $\lvert x\rvert$ at 0 shows.

## Fermat, Rolle and the mean value theorem

- **Fermat:** if f has a maximum or minimum at an interior point c and is differentiable there, $f'(c) = 0$.
- **Rolle:** if f is continuous on [a, b], differentiable inside, and f(a) = f(b), then $f'(c) = 0$ for some c in (a, b). (By the extreme value theorem f has an extreme point inside, unless it's constant.)
- **Mean value theorem:** if f is continuous on [a, b] and differentiable inside, then for some c in (a, b),

$$f(b) - f(a) = f'(c)(b - a)$$

(Apply Rolle to f minus its secant line.)

## Consequences

- $f' = 0$ on an interval means f is constant there; $f' > 0$ means f is increasing.
- If $\lvert f'\rvert \le L$, then $\lvert f(x) - f(y)\rvert \le L\lvert x - y\rvert$: f is Lipschitz.
- **Error propagation:** an input error Δ causes an output error at most $\max\lvert f'\rvert\cdot\lvert\Delta\rvert$, which is the rigorous version of linearized error analysis.
- If $f'$ has no zero on an interval, f has at most one root there (two roots would force a zero of f′ between them by Rolle).
:::

::: example
## Find c in the mean value theorem for $x^3$ on [0, 2].

::: solution
1. **Secant slope.**
   $$\begin{aligned} \frac{f(2) - f(0)}{2} &= \frac{8 - 0}{2} \\ &= 4 \end{aligned}$$
2. **Solve $f'(c) = 4$.** $3c^2 = 4$ gives
   $$\begin{aligned} c &= \frac{2}{\sqrt3} \\ &= 1.155 \end{aligned}$$
   inside (0, 2).
3. **Check with the general formula.** It gives $\sqrt{(0 + 0 + 4)/3}$, the same.

**Answer:** $c = \frac{2}{\sqrt3} = 1.155$.
:::
:::

::: example
## A resistor's power is $P = V^2/R$ with R = 100 Ω and V between 4.9 and 5.1 V. Bound the error in P if V is off by 0.02 V.

::: solution
1. **Differentiate.**
   $$\frac{dP}{dV} = \frac{2V}{R}$$
2. **Its largest value on the range.** At V = 5.1 V,
   $$\frac{2 \times 5.1}{100} = 0.102\ \text{W/V}$$
3. **Bound the error.**
   $$\begin{aligned} \lvert\Delta P\rvert &\le 0.102 \times 0.02\ \text{W} \\ &= 2.04\ \text{mW} \end{aligned}$$

**Answer:** the error in P is at most 2.04 mW.
:::
:::

::: example
## A sensor's output V(T) has a slope between 9 and 11 mV/K over its range. A reading changes by 50 mV. How much did the temperature change?

::: solution
1. **Apply the mean value theorem.** For some c between the two temperatures,
   $$\Delta V = V'(c)\Delta T$$
   with $9 \le V'(c) \le 11$ mV/K.
2. **Solve for ΔT.**
   $$\Delta T = \frac{\Delta V}{V'(c)}$$
3. **Bound it.** It lies between
   $$\frac{50}{11} = 4.55\ \text{K}$$
   and
   $$\frac{50}{9} = 5.56\ \text{K}$$
4. **How tight that is.** Without knowing where c is, that's as tight as the information allows, and it's guaranteed. A calibration that pins the slope more tightly narrows the range proportionally.

**Answer:** the temperature changed by between 4.55 K and 5.56 K.
:::
:::

::: check
given: a = 1 | 2 | -1; b = 3 | 4
answer: (a + b)/2
tolerance: 0.01%

## Where's the mean value point c for $x^2$ on [{a}, {b}]?

::: right
Right. The secant slope is a + b, and 2c = a + b: c = {answer}, the midpoint.
:::

::: misses
- [a + b] That's the secant slope, $f'(c)$; c solves 2c = a + b.
- [any] Not yet. Solve $2c = \frac{b^2 - a^2}{b - a}$.
:::
:::

::: check
given: b = 1 | 2 | 3
answer: b/sqrt(3)
tolerance: 0.01%

## Where's the mean value point c for $x^3$ on [0, {b}]?

::: right
Right. $3c^2 = b^2$ gives $c = b/\sqrt3$ = {answer}.
:::

::: misses
- [b/2] For a cubic it isn't the midpoint.
- [any] Not yet. Secant slope $b^2$; solve $3c^2 = b^2$.
:::
:::

::: check
given: L = 3 | 0.5 | 12; d = 0.01 | 0.002
answer: L*d
tolerance: 0.1%

## A function has $\lvert f'\rvert \le$ {L} everywhere. An input is off by at most {d}. What's the bound on the output error?

::: right
Right. $L\lvert\Delta\rvert$ = {answer}.
:::

::: misses
- [d/L] Multiply by the slope bound.
- [any] Not yet. $\lvert f(x + \Delta) - f(x)\rvert = \lvert f'(c)\rvert\lvert\Delta\rvert$.
:::
:::

::: check
given: R = 50 | 100 | 470; V = 5.1 | 12.2; d = 0.02 | 0.1
answer: 2*V/R*d*1000
unit: mW
tolerance: 0.5%

## $P = V^2/R$ with R = {R} Ω and V at most {V} V. If V is off by {d} V, bound the error in P.

::: right
Right. $\frac{2V_{max}}{R}\Delta V$ = {answer} mW.
:::

::: misses
- [V/R*d*1000] $\frac{dP}{dV} = \frac{2V}{R}$.
- [any] Not yet. Multiply the largest slope by the voltage error.
:::
:::

::: check
given: k = 2 | 7 | 30; d = 0.001 | 0.01
answer: k*d
tolerance: 0.1%

## How much can $\sin(\given{k}x)$ change when x changes by {d}?

::: right
Right. At most $k\lvert\Delta\rvert$ = {answer}.
:::

::: misses
- [d] The slope bound is k, not 1.
- [any] Not yet. $\lvert f'\rvert = \lvert k\cos kx\rvert \le k$.
:::
:::

::: check
kind: choice

## $f(x) = x^5 + 3x - c$. How many real roots can it have?

- [x] Exactly one: $f' = 5x^4 + 3 > 0$, so it's increasing and crosses zero once
- [ ] Up to five
- [ ] None
- [ ] Two

::: misses
- [2] A quintic can have five, but this one's derivative never vanishes, so by Rolle at most one; and it goes from −∞ to ∞, so at least one.
- [3] It's continuous and goes from −∞ to ∞: it must cross.
- [4] Two roots would force $f' = 0$ between them.
:::
:::

::: check
kind: order

## Put the steps of the proof of the mean value theorem in order.

1. Let $g(x) = f(x) - \left[f(a) + \frac{f(b) - f(a)}{b - a}(x - a)\right]$, f minus its secant line.
2. Then g(a) = g(b) = 0, and g is continuous on [a, b] and differentiable inside.
3. By Rolle's theorem, $g'(c) = 0$ for some c in (a, b).
4. $g'(c) = f'(c) - \frac{f(b) - f(a)}{b - a}$.
5. So $f'(c) = \frac{f(b) - f(a)}{b - a}$.

::: right
Right. Tilt the picture so the secant is level, and Rolle does the rest.
:::
:::

::: check
kind: parts
given: m = 9 | 20; M = 11 | 25; d = 50 | 100

## A sensor's slope stays between {m} and {M} mV/K. A reading changes by {d} mV.

::: part
answer: d/M
unit: K
tolerance: 0.5%

### What is the smallest temperature change consistent with that?

::: misses
- [d/m] That's the largest.
- [any] Divide by the largest slope.
:::
:::

::: part
answer: d/m
unit: K
tolerance: 0.5%

### And the largest?

::: misses
- [any] Divide by the smallest slope.
:::
:::
:::

::: check
kind: derivation
vars: a = 0.5..2, b = 2.5..5

## Find the mean value point c.

::: step
answer: ln((exp(b) - 1)/b)

### For $e^x$ on [0, b] (write b for the right end)?
:::

::: step
answer: sqrt(a*b)

### For $\frac1x$ on [a, b]?
:::

::: right
Right. For $\frac1x$ the point is the geometric mean of the ends.
:::
:::

::: explain
## Why does a bound on a function's derivative give a bound on how much the function can change, and why is that useful for error analysis?

::: model
The mean value theorem says the change $f(x + \Delta) - f(x)$ equals $f'(c)\Delta$ exactly, for some c between the two inputs. We don't know c, but if we know $\lvert f'\rvert \le L$ everywhere in that range, the change is at most $L\lvert\Delta\rvert$. That turns the usual linearized estimate, "output error ≈ slope × input error," into a guaranteed bound, valid however large Δ is, as long as the slope bound covers the whole range. For a measurement or a computation, it means a worst-case error can be stated without knowing exactly where the true input was.
:::
:::

::: practice

::: check
given: a = 0 | 3; b = 5 | 8
answer: (a + b)/2
tolerance: 0.01%

## Mean value point for $x^2$ on [{a}, {b}]?

::: misses
- [any] The midpoint.
:::
:::

::: check
given: b = 0.6 | 1 | 1.5 | 2 | 3 | 4
answer: b/sqrt(3)
tolerance: 0.01%

## Mean value point for $x^3$ on [0, {b}]?

::: misses
- [any] $b/\sqrt3$.
:::
:::

::: check
given: L = 6 | 0.2; d = 0.05 | 0.0003
answer: L*d
tolerance: 0.1%

## Output error bound, $\lvert f'\rvert \le$ {L}, input error {d}?

::: misses
- [any] $L\Delta$.
:::
:::
:::
