20. Average value and the Mean Value Theorem for integrals

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

The average of a finite list of numbers is their sum divided by how many there are. A continuous function has infinitely many values on an interval — there's no "how many" to divide by. This lesson defines the average of a function using exactly the sum-to-integral limit that's built every formula in this module, and then proves that average value is always achieved somewhere, a direct sibling of §3.4's Mean Value Theorem for derivatives.

Defining the average of a function

Sample f at n evenly spaced points on [a,b] and average those samples:

\frac1n\sum_{i=1}^nf(x_i)

Multiply and divide by \Delta x=\frac{b-a}n to turn this into something that looks like a Riemann sum:

\frac1n\sum f(x_i)=\frac{1}{b-a}\sum f(x_i)\,\Delta x

As n\to\infty, the sum becomes an integral (§4.2), giving the average value of f on [a,b]:

f_{\text{avg}}=\frac1{b-a}\int_a^bf(x)\,dx

This is the \frac1A\int(\cdot) pattern from §5.5's centroid formulas with A replaced by the interval length b-a — averaging a function's value is structurally identical to averaging a region's position, just with a different weight sitting inside the integral.

The Mean Value Theorem for integrals

Rearrange the definition: \displaystyle\int_a^bf(x)\,dx=f_{\text{avg}}\cdot(b-a) — the exact integral equals the average value times the interval length, which is exactly what §4.2's "area of a rectangle with height f_{\text{avg}}" would give. The Mean Value Theorem for integrals guarantees that this height is not just a hypothetical average — it's a value f actually takes:

If f is continuous on [a,b], there exists at least one c\in[a,b] such that f(c)=f_{\text{avg}}=\frac1{b-a}\int_a^bf(x)\,dx

Why continuity is enough. By the Extreme Value Theorem (§1.8), a continuous f attains a minimum m and maximum M on [a,b], so m\le f_{\text{avg}}\le M (the average of a bounded function can't exceed its extremes). By the Intermediate Value Theorem (§1.8, again), f must hit every value between m and M somewhere in [a,b] — including f_{\text{avg}} itself. No new machinery is needed — this theorem falls straight out of two results already proven in Module 1.

The geometric picture: among all rectangles with base b-a sitting on [a,b], exactly one has the same area as the region under the curve — the one with height f_{\text{avg}} — and the MVT guarantees the curve actually touches that rectangle's height somewhere in the interval.

Connection to the derivative Mean Value Theorem

§3.4's Mean Value Theorem said a differentiable function's instantaneous rate of change equals its average rate of change somewhere on [a,b]: f'(c)=\frac{f(b)-f(a)}{b-a}. Apply this lesson's theorem to f' itself (if f' is continuous):

f'_{\text{avg}}=\frac1{b-a}\int_a^bf'(x)\,dx=\frac{f(b)-f(a)}{b-a}

by the Fundamental Theorem (§4.3) — the average value of the derivative equals the average rate of change of the original function. The two Mean Value Theorems, one for derivatives and one for integrals, turn out to be two views of the same fact once the Fundamental Theorem connects them.

Doing it in Python

Average value of f(x)=x^2 on [0,3], then solving for where f actually hits that average:

import sympy as sp

x = sp.Symbol('x')
f = x**2
a, b = 0, 3

f_avg = sp.integrate(f, (x, a, b)) / (b - a)
print(f"average value of x^2 on [{a},{b}] = {f_avg}")

candidates = sp.solve(sp.Eq(f, f_avg), x)
c = [v for v in candidates if a <= v <= b][0]
print(f"c in [{a},{b}] where f(c) = f_avg : c = {c}")

Confirming the rectangle-area picture directly — the average-height rectangle has the same area as the region under the curve:

import sympy as sp

x = sp.Symbol('x')
f = sp.sin(x)
a, b = 0, sp.pi

exact_area = sp.integrate(f, (x, a, b))
f_avg = exact_area / (b - a)
rectangle_area = f_avg * (b - a)
print(f"area under sin(x) on [0,pi]     = {exact_area}")
print(f"average-height rectangle's area = {sp.simplify(rectangle_area)}")
print(f"equal: {sp.simplify(exact_area - rectangle_area) == 0}")

The two Mean Value Theorems agreeing, using f(x)=x^3 on [0,2]:

import sympy as sp

x = sp.Symbol('x')
f = x**3
fp = sp.diff(f, x)
a, b = 0, 2

avg_rate_of_change = (f.subs(x, b) - f.subs(x, a)) / (b - a)
avg_value_of_derivative = sp.integrate(fp, (x, a, b)) / (b - a)
print(f"average rate of change of f, (f(b)-f(a))/(b-a) = {avg_rate_of_change}")
print(f"average value of f' over [a,b]                 = {avg_value_of_derivative}")
print(f"same number: {avg_rate_of_change == avg_value_of_derivative}")

Worked example

Find the average value of f(x)=x^2 on [0,3], and find a c\in[0,3] guaranteed by the Mean Value Theorem for integrals.

f_{\text{avg}}=\frac1{3-0}\int_0^3x^2dx=\frac13\left[\frac{x^3}3\right]_0^3=\frac13\cdot9=\boxed{3}

Solve f(c)=3: c^2=3\Rightarrow c=\pm\sqrt3. Only c=\sqrt3\approx1.73 lies in [0,3], so that's the guaranteed point.

Sanity check. f(0)=0 and f(3)=9, so the average value 3 sits between the function's minimum and maximum on the interval, as the theorem's proof required. And \sqrt3 is closer to x=0 than to x=3 — which makes sense, since x^2 grows slowly near 0 and steeply near 3, so more of the interval sits at low function values, pulling the "achieves the average" point toward the low end. ✓

Your turn

1. Find the average value of f(x)=4-x^2 on [-2,2]. Symmetry is worth noticing here — but decide carefully whether it hands you the answer or merely halves the work.

2. Find the average value of f(x)=\cos x on [0,\frac\pi2], and find the guaranteed c.

3. True or false: the Mean Value Theorem for integrals guarantees a unique c — exactly one point where f equals its average.

Solutions

1. f(x)=4-x^2 is even (symmetric about x=0), and [-2,2] is symmetric about 0 too — worth checking whether that simplifies things, but the average isn't obvious from symmetry alone here since f isn't symmetric about its own average. Compute directly:

f_{\text{avg}}=\frac1{4}\int_{-2}^2(4-x^2)dx=\frac14\left[4x-\frac{x^3}3\right]_{-2}^2=\frac14\left[\left(8-\frac83\right)-\left(-8+\frac83\right)\right]=\frac14\cdot\frac{32}3=\boxed{\frac83}

2.

f_{\text{avg}}=\frac{1}{\pi/2}\int_0^{\pi/2}\cos x\,dx=\frac2\pi\Big[\sin x\Big]_0^{\pi/2}=\frac2\pi(1-0)=\boxed{\frac2\pi}

Solving \cos c=\frac2\pi\approx0.6366: c=\arccos\!\left(\frac2\pi\right)\approx0.881, which lies in \left[0,\frac\pi2\right]\approx[0,1.571]. ✓

3. False. The theorem guarantees at least one such c, not exactly one. A function that oscillates — say, one that dips below its average, rises above it, and dips again — can cross its own average value multiple times within [a,b]; the theorem only promises the crossing happens at all, the same way the Intermediate Value Theorem it relies on (§1.8) never promised uniqueness either.

Check yourself in code

Compute the average value of f(x)=x^2 on [0,3], and the value c\in[0,3] where f(c) equals that average.

Print exactly this:

average value of x^2 on [0,3] = 3
c in [0,3] where f(c) = average = sqrt(3)
import sympy as sp

x = sp.Symbol('x')
f = x**2
a, b = 0, 3

f_avg = sp.integrate(f, (x, a, b)) / (b - a)
print("average value of x^2 on [0,3] = ...")

candidates = sp.solve(sp.Eq(f, f_avg), x)
c = [v for v in candidates if a <= v <= b][0]
print("c in [0,3] where f(c) = average = ...")
import sympy as sp

x = sp.Symbol('x')
f = x**2
a, b = 0, 3

f_avg = sp.integrate(f, (x, a, b)) / (b - a)
print(f"average value of x^2 on [0,3] = {f_avg}")

candidates = sp.solve(sp.Eq(f, f_avg), x)
c = [v for v in candidates if a <= v <= b][0]
print(f"c in [0,3] where f(c) = average = {c}")

The average value of a function, f_{\text{avg}}=\frac1{b-a}\int_a^bf\,dx, is the height of the single rectangle over [a,b] whose area matches the area under the curve — and the Mean Value Theorem for integrals guarantees f actually reaches that height somewhere on the interval, a consequence of the Extreme Value and Intermediate Value Theorems from §1.8 rather than new machinery. Applied to a derivative, it recovers §3.4's Mean Value Theorem exactly, with the Fundamental Theorem as the bridge between the two.

Next: one more use for "the value a function achieves on average" — treating that function as a probability density, where the area under a curve stops measuring geometry and starts measuring likelihood.