1. Antiderivatives: running the derivative backwards

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

Module 2 left you able to differentiate anything, and Module 3 spent nine lessons putting that to work. Now try it in reverse: given f, find a function whose derivative is f.

F'(x) = f(x)

F is an antiderivative of f. Note the article — antiderivatives are never unique, which turns out to be the most important structural fact about them.

Why "+C"

If F' = f, then (F + 7)' = f as well, since constants differentiate to zero. So there are infinitely many antiderivatives.

And that's all of them. If F' = G' = f on an interval, then (F-G)' = 0, so F - G is constant by the Mean Value Theorem (§3.4).

\int f(x)\,dx = F(x) + C

The indefinite integral notation means "the whole family of antiderivatives", and the +C is not decoration — it's a theorem, and the MVT is what proves it.

The caveat that matters: "on an interval". For f(x) = \frac1x, the antiderivative on (0,\infty) and on (-\infty,0) can have different constants, because the domain is disconnected and the MVT can't bridge the gap. The honest general antiderivative is

\int\frac{dx}{x} = \begin{cases}\ln x + C_1 & x>0\\ \ln(-x)+C_2 & x<0\end{cases}

usually compressed to \ln|x| + C, which is fine as long as you never integrate across zero. §4.10 shows what goes wrong when you do.

The table, read backwards

Every derivative rule from §2 is an antiderivative rule read right-to-left:

f(x) \int f(x)\,dx
x^n, n\neq-1 \dfrac{x^{n+1}}{n+1}+C
\dfrac1x \ln\lvert x\rvert + C
e^x e^x + C
b^x \dfrac{b^x}{\ln b}+C
\cos x \sin x + C
\sin x -\cos x + C
\sec^2x \tan x + C
\sec x\tan x \sec x + C
\dfrac{1}{\sqrt{1-x^2}} \arcsin x + C
\dfrac{1}{1+x^2} \arctan x + C
\cosh x \sinh x + C

The power rule's exception is the whole reason \ln is here. The formula \frac{x^{n+1}}{n+1} divides by zero at n=-1, and the function that fills the gap is the logarithm (§2.6). That single exception is why \frac1x behaves unlike every other power throughout this course — in improper integrals (§4.10), in p-series (§7.6), and in complexity analysis.

Linearity, and what it doesn't include

\int\left[af(x)+bg(x)\right]dx = a\int f(x)\,dx + b\int g(x)\,dx

which follows from differentiation being linear.

There is no product rule, no quotient rule, and no chain rule for antiderivatives.

\int f(x)g(x)\,dx \neq \left(\int f\right)\left(\int g\right)

Substitution (§4.5) is a partial inverse of the chain rule, and integration by parts (§4.6) is a partial inverse of the product rule — but both are techniques requiring judgement, not formulas you apply blindly.

This asymmetry is the defining feature of the subject. Differentiation is algorithmic: any expression built from elementary functions can be differentiated by mechanically applying rules, and the answer is another elementary function. Integration is not. Even simple-looking integrands may have no elementary antiderivative at all:

\int e^{-x^2}dx, \qquad \int\frac{\sin x}{x}dx, \qquad \int\frac{dx}{\ln x}, \qquad \int\sqrt{1+x^3}\,dx

None of these can be written with elementary functions. That's a theorem (Liouville, 1835), not a confession of ignorance. §4.12 discusses what to do instead.

The first is \frac{\sqrt\pi}{2}\operatorname{erf}(x) — the Gaussian, whose definite integral over (-\infty,\infty) is beautifully computable (§11.5) even though its indefinite integral is not.

Always verifiable

Integration is hard to do and trivial to check: differentiate your answer.

\int x\cos x\,dx = x\sin x + \cos x + C

Check: $\frac{d}{dx}\left[x\sin x + \cos x\right] = \sin x + x\cos x - \sin x = x\cos x$ ✓.

There is no excuse for a wrong antiderivative. Make checking a reflex.

Initial value problems

The +C becomes a specific number once you know one value.

A ball is thrown upward at 20 m/s from a height of 2 m. Find its height.

a(t) = -9.8 \implies v(t) = \int -9.8\,dt = -9.8t + C_1

v(0) = 20 gives C_1 = 20, so v(t) = -9.8t + 20.

s(t) = \int(-9.8t+20)\,dt = -4.9t^2+20t+C_2

s(0)=2 gives C_2 = 2:

s(t) = -4.9t^2+20t+2

Two integrations, two constants, two initial conditions. That correspondence is the entire structure of §13's differential equations: an n-th order equation has an n-parameter family of solutions, and needs n conditions to pin one down.

Doing it in Python

Every antiderivative, checked by differentiating back:

import sympy as sp

x = sp.Symbol('x', positive=True)

table = [
    (x**3, x**4/4), (1/x, sp.log(x)), (sp.cos(x), sp.sin(x)),
    (sp.exp(x), sp.exp(x)), (1/(1+x**2), sp.atan(x)),
    (sp.sec(x)**2, sp.tan(x)), (1/sp.sqrt(1-x**2), sp.asin(x)),
]

print(f"{'f':>18} {'claimed F':>18} {'F-prime':>20} {'ok':>6}")
for f, F in table:
    back = sp.simplify(sp.diff(F, x))
    print(f"{str(f):>18} {str(F):>18} {str(back):>20} "
          f"{str(sp.simplify(back - f) == 0):>6}")

The +C, and the family it describes:

import sympy as sp

x, C = sp.symbols('x C')
f = 3*x**2

print(f"f(x) = {f}")
print(f"one antiderivative : {sp.integrate(f, x)}")
print(f"the whole family   : {sp.integrate(f, x)} + C\n")

for c in (-2, 0, 5):
    F = x**3 + c
    print(f"  F = {F},  F' = {sp.diff(F, x)}")

print("\nsame derivative, different curves -- vertically shifted copies")

The integrals with no elementary answer:

import sympy as sp

x = sp.Symbol('x')

for f in (sp.exp(-x**2), sp.sin(x)/x, 1/sp.log(x), sp.sqrt(1 + x**3)):
    result = sp.integrate(f, x)
    print(f"int {str(f):<16} dx = {result}")

print("\nsympy answers with special functions (erf, Si, li) or gives up.")
print("that is not a limitation of sympy: Liouville proved in 1835 that no")
print("elementary antiderivative exists for these.")

The initial value problem, integrated twice:

import sympy as sp

t = sp.Symbol('t')
C1, C2 = sp.symbols('C1 C2')

a = -sp.Rational(49, 5)          # -9.8
v = sp.integrate(a, t) + C1
c1 = sp.solve(sp.Eq(v.subs(t, 0), 20), C1)[0]
v = v.subs(C1, c1)

s = sp.integrate(v, t) + C2
c2 = sp.solve(sp.Eq(s.subs(t, 0), 2), C2)[0]
s = s.subs(C2, c2)

print(f"a(t) = {a}")
print(f"v(t) = {v}")
print(f"s(t) = {s}\n")
print(f"peak at t = {sp.solve(v, t)[0]} s, height {sp.solve(v, t)[0] and s.subs(t, sp.solve(v, t)[0])}")
print(f"lands at t = {max(sp.solve(s, t)):.4f} s")

Worked example

Find \int\left(3x^2 - \dfrac{4}{x} + \sqrt{x} + e^x\right)dx.

Linearity splits it into four, and each is a table lookup after rewriting roots as powers:

\int3x^2dx = 3\cdot\frac{x^3}{3} = x^3

\int-\frac4x dx = -4\ln|x|

\int\sqrt x\,dx = \int x^{1/2}dx = \frac{x^{3/2}}{3/2} = \frac23x^{3/2}

\int e^xdx = e^x

\boxed{x^3 - 4\ln|x| + \tfrac23x^{3/2} + e^x + C}

One C for the whole thing, not one per term — the sum of four arbitrary constants is one arbitrary constant.

Check by differentiating:

3x^2 - \frac4x + \frac23\cdot\frac32 x^{1/2} + e^x = 3x^2 - \frac4x + \sqrt x + e^x \quad\checkmark

A domain note that's easy to skip. \sqrt x requires x \ge 0 while \ln|x| allows x\ne0, so this antiderivative is only valid on (0,\infty). The |x| is redundant there, and writing \ln x would be equally correct — but only because the other term already restricted the domain.

Your turn

1. \displaystyle\int\left(x^4 - 3x^2 + 7\right)dx

2. \displaystyle\int\frac{x^2+1}{x}dx

3. \displaystyle\int\left(2\sec^2x - \frac{5}{1+x^2}\right)dx

4. Find f given f''(x) = 6x, f'(0)=2, f(0)=1.

Solutions

1. Power rule on each term:

\boxed{\frac{x^5}{5} - x^3 + 7x + C}

2. Divide first — the recurring §2.2 lesson:

\frac{x^2+1}{x} = x + \frac1x

\int\left(x+\frac1x\right)dx = \boxed{\frac{x^2}{2} + \ln|x| + C}

Attempting this without dividing gets you nowhere, since there's no quotient rule to reverse.

3. Two table entries:

\boxed{2\tan x - 5\arctan x + C}

Worth noticing how easily \tan and \arctan are confused here. \int\sec^2 = \tan and \int\frac{1}{1+x^2} = \arctan — the second is the inverse function, and it comes from §2.7's inverse-trig derivative, not from anything trigonometric in the integrand.

4. Integrate twice, applying a condition after each.

f'(x) = \int6x\,dx = 3x^2 + C_1

f'(0) = 2 gives C_1 = 2, so f'(x) = 3x^2+2.

f(x) = \int(3x^2+2)dx = x^3+2x+C_2

f(0)=1 gives C_2 = 1:

\boxed{f(x) = x^3+2x+1}

Apply each condition as soon as you can. Carrying both constants to the end and solving a system works, but it's more error-prone — and in §13 with higher-order equations it becomes genuinely painful.

Check yourself in code

Verify five antiderivatives by differentiating them back.

For F = \frac{x^4}{4}, \ln x, \sin x, e^x, \arctan x, print F, F', and whether F' matches the intended f (x^3, \frac1x, \cos x, e^x, \frac{1}{1+x^2}). Use a positive symbol so SymPy keeps the logarithm simple.

Print exactly this:

F = x**4/4     F' = x**3           matches: True
F = log(x)     F' = 1/x            matches: True
F = sin(x)     F' = cos(x)         matches: True
F = exp(x)     F' = exp(x)         matches: True
F = atan(x)    F' = 1/(x**2 + 1)   matches: True
import sympy as sp

x = sp.Symbol('x', positive=True)

pairs = [
    (x**4/4, x**3),
    (sp.log(x), 1/x),
    (sp.sin(x), sp.cos(x)),
    (sp.exp(x), sp.exp(x)),
    (sp.atan(x), 1/(1 + x**2)),
]

for F, f in pairs:
    # differentiate F and check it equals f
    print(f"F = {str(F):<10} ...")
import sympy as sp

x = sp.Symbol('x', positive=True)

pairs = [
    (x**4/4, x**3),
    (sp.log(x), 1/x),
    (sp.sin(x), sp.cos(x)),
    (sp.exp(x), sp.exp(x)),
    (sp.atan(x), 1/(1 + x**2)),
]

for F, f in pairs:
    back = sp.diff(F, x)
    ok = sp.simplify(back - f) == 0
    print(f"F = {str(F):<10} F' = {str(back):<14} matches: {ok}")

An antiderivative reverses differentiation, and they come in families differing by a constant — a fact the Mean Value Theorem proves rather than a convention. The table is §2's derivative rules read backwards, with \frac1x \to \ln|x| plugging the hole the power rule leaves at n=-1. Antiderivatives are linear and nothing more: no product, quotient, or chain rule exists, and some perfectly ordinary functions have no elementary antiderivative at all. Always check by differentiating.

Next: the other kind of integral — which starts as a completely different question about area, and turns out not to be.