4. The Fundamental Theorem, part 1: differentiating an area

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

Two problems, introduced separately, worked on separately. §2 found tangent slopes. §4.1 found areas. Nothing so far connects them.

This lesson connects them, and the connection is the reason calculus is one subject rather than two.

The accumulation function

Let f be continuous on [a,b] and define

g(x) = \int_a^x f(t)\,dt

For each x, g(x) is the accumulated signed area from a out to x. As x moves right, g accumulates more.

Read the notation carefully. t is the dummy integration variable; x is the upper limit and the input to g. Using x for both is the standard first mistake and makes the expression meaningless.

The theorem

If f is continuous on [a,b], then g(x)=\int_a^xf(t)\,dt is differentiable on (a,b) and g'(x) = f(x)

Differentiating an accumulated area gives back the function you accumulated. Every continuous function has an antiderivative, and this is it.

Why it's true

Compute g' from the definition. The numerator of the difference quotient is

g(x+h)-g(x) = \int_a^{x+h}f - \int_a^xf = \int_x^{x+h}f

by additivity (§4.2). That's the area of a thin sliver of width h.

By the Mean Value Theorem for integrals, there's a c in [x,x+h] with

\int_x^{x+h}f = f(c)\cdot h

So

\frac{g(x+h)-g(x)}{h} = f(c)

As h\to0, c is squeezed between x and x+h, so c\to x; and because f is continuous, f(c)\to f(x). Hence g'(x)=f(x). \blacksquare

The sliver is the whole idea. Widen the region by dx and you gain a strip of height f(x) and width dx — area f(x)\,dx. So \frac{dg}{dx} = f(x).

That's the same argument as §0.1's: grow a disc's radius and you gain a ring whose area is the circumference times the thickness, so \frac{dA}{dr} = C. You've seen the Fundamental Theorem before; it was a circle.

What it means

Every continuous function has an antiderivative. That is not obvious. §4.0 listed functions like e^{-x^2} whose antiderivatives can't be written with elementary functions — but this theorem says one exists regardless, defined by an integral. That's precisely what \operatorname{erf} is:

\operatorname{erf}(x) = \frac{2}{\sqrt\pi}\int_0^xe^{-t^2}dt

Not a trick, and not a dodge. Defining a function by an integral is as legitimate as defining one by a formula, and it's how \ln, \operatorname{erf}, the logarithmic integral, and the Fresnel functions are all defined.

Differentiation and integration are inverse operations. Integrate then differentiate, and you're back where you started.

With the chain rule

The most common exam use, and worth having as a formula.

If the upper limit is a function of x:

\frac{d}{dx}\int_a^{u(x)}f(t)\,dt = f(u(x))\cdot u'(x)

because g(u(x)) is a composition, and g' = f.

If the lower limit varies, flip it first using the sign convention:

\frac{d}{dx}\int_{v(x)}^{b}f(t)\,dt = -f(v(x))\cdot v'(x)

And with both varying, split at any convenient point:

\frac{d}{dx}\int_{v(x)}^{u(x)}f = f(u)u' - f(v)v'

Doing it in Python

The accumulation function and its derivative:

def integrate(f, a, b, n=20000):
    w = (b - a) / n
    return sum(f(a + (i + 0.5) * w) for i in range(n)) * w

f = lambda t: t * t

def g(x):
    return integrate(f, 0, x)

h = 1e-4
print(f"{'x':>6} {'g(x)':>12} {'x^3/3':>12} {'g-prime(x)':>14} {'f(x)=x^2':>12}")
for x in (0.5, 1.0, 1.5, 2.0):
    slope = (g(x + h) - g(x - h)) / (2 * h)
    print(f"{x:>6} {g(x):>12.6f} {x**3/3:>12.6f} {slope:>14.6f} {x*x:>12.6f}")

print("\nthe derivative of the accumulated area IS the integrand")

Watching the sliver:

def integrate(f, a, b, n=20000):
    w = (b - a) / n
    return sum(f(a + (i + 0.5) * w) for i in range(n)) * w

from math import sin
x = 1.2

print(f"f(x) = sin(x) = {sin(x):.8f}\n")
print(f"{'h':>10} {'sliver area':>16} {'area / h':>14}")
for k in range(1, 7):
    h = 10.0 ** -k
    sliver = integrate(sin, x, x + h, n=2000)
    print(f"{h:>10.0e} {sliver:>16.3e} {sliver/h:>14.8f}")

print("\nthe thin sliver has area about f(x)*h, so area/h -> f(x)")

The chain-rule version:

import sympy as sp

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

cases = [
    ("int_0^x t^2 dt", sp.Integral(t**2, (t, 0, x))),
    ("int_0^(x^2) sin(t) dt", sp.Integral(sp.sin(t), (t, 0, x**2))),
    ("int_x^3 e^t dt", sp.Integral(sp.exp(t), (t, x, 3))),
    ("int_(x)^(x^2) t dt", sp.Integral(t, (t, x, x**2))),
]

for name, I in cases:
    print(f"d/dx [{name:<24}] = {sp.simplify(sp.diff(I.doit(), x))}")

A function with no elementary antiderivative, defined by an integral anyway:

from math import exp, sqrt, pi, erf

def integrate(f, a, b, n=100000):
    w = (b - a) / n
    return sum(f(a + (i + 0.5) * w) for i in range(n)) * w

def my_erf(x):
    return 2 / sqrt(pi) * integrate(lambda t: exp(-t*t), 0, x)

print(f"{'x':>6} {'our integral':>16} {'math.erf':>16} {'derivative':>16} "
      f"{'2/sqrt(pi) e^-x^2':>20}")
h = 1e-5
for x in (0.5, 1.0, 1.5, 2.0):
    d = (my_erf(x + h) - my_erf(x - h)) / (2 * h)
    print(f"{x:>6} {my_erf(x):>16.10f} {erf(x):>16.10f} {d:>16.8f} "
          f"{2/sqrt(pi)*exp(-x*x):>20.8f}")

print("\nerf has no elementary formula, and is a perfectly good function")
print("with a perfectly computable derivative -- because of this theorem")

Worked example

Find \dfrac{d}{dx}\displaystyle\int_{2}^{x^3}\sqrt{1+t^4}\;dt.

The integrand \sqrt{1+t^4} has no elementary antiderivative, so you cannot evaluate the integral and then differentiate. The theorem lets you skip that entirely.

Outer limit u(x)=x^3, so u'(x)=3x^2:

\frac{d}{dx}\int_2^{x^3}\sqrt{1+t^4}\,dt = \sqrt{1+(x^3)^4}\cdot3x^2 = \boxed{3x^2\sqrt{1+x^{12}}}

Substitute the upper limit into the integrand and multiply by its derivative. That's the whole procedure.

A harder variant, both limits moving:

\frac{d}{dx}\int_{\sin x}^{x^2}e^{t^2}dt

Split at any convenient constant, say 0:

= \frac{d}{dx}\left[\int_0^{x^2}e^{t^2}dt - \int_0^{\sin x}e^{t^2}dt\right]

= e^{x^4}\cdot 2x - e^{\sin^2x}\cdot\cos x

Upper limit contributes positively, lower limit negatively, each multiplied by its own derivative. The split point never appears in the answer, which it can't — it was arbitrary.

Your turn

1. \dfrac{d}{dx}\displaystyle\int_1^x\frac{1}{1+t^2}\,dt, and identify the function.

2. \dfrac{d}{dx}\displaystyle\int_0^{x^2}\cos(t)\,dt — two ways.

3. \dfrac{d}{dx}\displaystyle\int_{x}^{5}\ln(t)\,dt

4. If g(x) = \int_0^x f(t)dt with f continuous and positive, what can you say about g?

Solutions

1. Directly: \boxed{\dfrac{1}{1+x^2}}.

And the function itself is \arctan x - \arctan 1 = \arctan x - \frac\pi4, since \frac{1}{1+t^2} has antiderivative \arctan (§2.7). Consistent: differentiating gives \frac{1}{1+x^2} ✓.

This is one way to define \arctan — and the integral definition is often the cleaner one, since it makes the derivative obvious and the arithmetic of the inverse-trig restrictions disappear.

2. Chain rule version. u = x^2, u' = 2x:

\cos(x^2)\cdot2x = \boxed{2x\cos(x^2)}

Evaluate first. \int_0^{x^2}\cos t\,dt = \sin(x^2) - \sin 0 = \sin(x^2), and differentiating gives 2x\cos(x^2) ✓.

Both work here because \cos has an easy antiderivative. For \sqrt{1+t^4} only the first route exists — which is the point of the theorem.

3. The variable is the lower limit, so flip and negate:

\frac{d}{dx}\int_x^5\ln t\,dt = -\frac{d}{dx}\int_5^x\ln t\,dt = \boxed{-\ln x}

Sensible: increasing x shrinks the interval [x,5] from the left, removing area, so the accumulated value decreases.

4. Three things, in increasing strength.

g is differentiable with g' = f, hence continuous.

g is strictly increasing, since g' = f > 0 everywhere (§3.4's MVT corollary).

g(0) = 0, and g is the antiderivative of f vanishing at 0 — every other one differs from it by a constant.

If additionally f is increasing, then g'' = f' > 0 and g is concave up. So an accumulation function inherits its shape from the integrand's values, and its concavity from the integrand's slope — one order shifted, which is exactly what "antiderivative" means.

Check yourself in code

Verify the theorem numerically: build g(x) = \int_0^x t^2\,dt with a midpoint rule, then differentiate it and check you get x^2 back.

Use n = 20000 midpoint rectangles and a central difference with h=10^{-4}. Print for x = 0.5, 1.0, 1.5, 2.0.

Print exactly this:

x=0.5  g'(x)=0.250000  x^2=0.250000
x=1.0  g'(x)=1.000000  x^2=1.000000
x=1.5  g'(x)=2.250000  x^2=2.250000
x=2.0  g'(x)=4.000000  x^2=4.000000
def g(u, n=20000):
    """Midpoint-rule approximation to the integral of t^2 from 0 to u."""
    w = u / n
    return sum(((i + 0.5) * w) ** 2 for i in range(n)) * w

h = 1e-4
for x in (0.5, 1.0, 1.5, 2.0):
    # central-difference g'(x), then compare to x^2
    print(f"x={x}  ...")
def g(u, n=20000):
    """Midpoint-rule approximation to the integral of t^2 from 0 to u."""
    w = u / n
    return sum(((i + 0.5) * w) ** 2 for i in range(n)) * w

h = 1e-4
for x in (0.5, 1.0, 1.5, 2.0):
    print(f"x={x}  g'(x)={(g(x + h) - g(x - h)) / (2 * h):.6f}  x^2={x*x:.6f}")

\frac{d}{dx}\int_a^xf(t)\,dt = f(x): differentiating an accumulated area returns the integrand, because widening the region by dx adds a sliver of area f(x)\,dx. Two consequences. Every continuous function has an antiderivative — even the ones with no elementary formula, which is exactly how \operatorname{erf} and friends are defined. And differentiation and integration are inverse operations, which is what makes calculus one subject.

Next: the same theorem read the other way, which is what turns integration from a limit of sums into a lookup.