Chapter 15 gave you the two workhorses of integration: $u$-substitution (the reverse chain rule) and integration by parts (the reverse product rule). Between them they dispatch the majority of integrals that arise in scientific work. But "the...
Prerequisites
- chapter-15-integration-techniques-i
Learning Objectives
- Evaluate integrals of the form $\int \sin^m x \cos^n x \, dx$ using identities and substitution
- Apply trigonometric substitution to integrals containing $\sqrt{a^2 - x^2}$, $\sqrt{a^2 + x^2}$, or $\sqrt{x^2 - a^2}$
- Decompose rational functions into partial fractions and integrate term by term
- Apply the trapezoidal rule and Simpson's rule for numerical approximation
- Estimate the error in numerical integration
- Recognize when an integral has no elementary antiderivative and switch to numerical methods
In This Chapter
Integration Techniques II: Trigonometric, Partial Fractions, and Numerical Methods
16.1 Four Techniques, One Strategy
Chapter 15 gave you the two workhorses of integration: $u$-substitution (the reverse chain rule) and integration by parts (the reverse product rule). Between them they dispatch the majority of integrals that arise in scientific work. But "the majority" is not "all," and the gaps are not exotic — they are the integrals that show up the moment you compute the length of an ellipse, the charge on a capacitor, the area under a bell curve, or the resonance of an electrical circuit.
This chapter closes those gaps with three more analytic techniques and one numerical fallback:
- Trigonometric integrals — products and powers of $\sin$, $\cos$, $\tan$, and $\sec$, untangled by trigonometric identities and a well-chosen substitution.
- Trigonometric substitution — for integrands containing $\sqrt{a^2 - x^2}$, $\sqrt{a^2 + x^2}$, or $\sqrt{x^2 - a^2}$, you set $x$ equal to a trig function so the radical melts into a clean trig expression. This chapter is the canonical home of the technique; later chapters that need it will point back here.
- Partial fraction decomposition — every rational function $p(x)/q(x)$ can be split into a sum of pieces simple enough to integrate by inspection.
- Numerical integration — when no elementary antiderivative exists at all (and Chapter 14 warned you that most integrands have none), the trapezoidal and Simpson's rules deliver arbitrary precision from nothing but values of the integrand.
The Key Insight. Each analytic technique is a change of disguise. Trig integrals trade powers for identities; trig substitution trades a radical for a triangle; partial fractions trade one hard fraction for several easy ones. The art of integration is not brute force — it is recognizing which disguise to strip away. And when no disguise works, that is not defeat: it is the signal to compute numerically, which always works.
By the end of the chapter you will own every major integration technique. What remains for the rest of your calculus life is practice and pattern recognition — and a decision tree (§16.7) for choosing the right tool fast.
This material also leans on three of the book's recurring themes: that geometry and algebra are inseparable (trig substitution is literally a right triangle), that hand computation builds understanding while machine computation builds power (every result here is verified in sympy), and that approximation is the soul of calculus (numerical integration is approximation made rigorous, with error bounds you can trust).
16.2 Trigonometric Integrals
Integrals built from powers and products of $\sin$ and $\cos$ — and of $\tan$ and $\sec$ — are everywhere in physics and engineering, because oscillations, waves, and alternating currents are all sinusoidal. The strategy is always the same: use an identity to free up one factor as the differential, then substitute. The four identities that do all the work are
$$\sin^2 x + \cos^2 x = 1, \qquad 1 + \tan^2 x = \sec^2 x,$$ $$\sin^2 x = \frac{1 - \cos 2x}{2}, \qquad \cos^2 x = \frac{1 + \cos 2x}{2}.$$
The first two are Pythagorean identities (they convert between functions); the last two are power-reduction identities (they lower exponents). Knowing which to reach for is the entire skill.
Case 1 — $\displaystyle\int \sin^m x \cos^n x\,dx$ with $m$ odd
Peel off one factor of $\sin x$ to pair with $dx$. Convert the remaining even power $\sin^{m-1}x$ to cosines using $\sin^2 x = 1 - \cos^2 x$. Then substitute $u = \cos x$, $du = -\sin x\,dx$. The lone $\sin x$ you set aside is exactly what $du$ needs.
Worked Example 16.2.1. Evaluate $\displaystyle\int \sin^3 x \cos^2 x\,dx$.
Split off one sine: $\sin^3 x = \sin x \cdot \sin^2 x = \sin x\,(1 - \cos^2 x)$. So
$$\int \sin^3 x \cos^2 x\,dx = \int \sin x\,(1 - \cos^2 x)\,\cos^2 x\,dx.$$
Let $u = \cos x$, $du = -\sin x\,dx$:
$$= -\int (1 - u^2)\,u^2\,du = -\int (u^2 - u^4)\,du = -\frac{u^3}{3} + \frac{u^5}{5} + C = -\frac{\cos^3 x}{3} + \frac{\cos^5 x}{5} + C.$$
Notice the trade-off: the odd power gave up one factor to become a differential, and the even power converted cleanly into a polynomial in $u$. That is the whole machinery.
Case 2 — $\displaystyle\int \sin^m x \cos^n x\,dx$ with $n$ odd
Mirror image of Case 1: peel off one $\cos x$ for $du$, convert the remaining even power $\cos^{n-1}x$ via $\cos^2 x = 1 - \sin^2 x$, and substitute $u = \sin x$.
Worked Example 16.2.2. Evaluate $\displaystyle\int \cos^5 x\,dx$ (here $m = 0$, $n = 5$ odd).
Write $\cos^5 x = \cos^4 x\,\cos x = (1 - \sin^2 x)^2\,\cos x$. Substitute $u = \sin x$, $du = \cos x\,dx$:
$$\int (1 - u^2)^2\,du = \int (1 - 2u^2 + u^4)\,du = u - \frac{2u^3}{3} + \frac{u^5}{5} + C = \sin x - \frac{2\sin^3 x}{3} + \frac{\sin^5 x}{5} + C.$$
Check Your Understanding. Before reading the next case: which substitution would you use for $\displaystyle\int \sin^4 x \cos^3 x\,dx$ — $u = \sin x$ or $u = \cos x$?
Answer
The cosine power is odd ($n=3$), so peel off one $\cos x$ for $du$ and convert the rest with $\cos^2 x = 1-\sin^2 x$. Use $u = \sin x$. The sine power being even ($m=4$) does not matter — it just rides along as $u^4$. You would get $\int u^4(1-u^2)\,du = \tfrac{\sin^5 x}{5} - \tfrac{\sin^7 x}{7} + C$.
Case 3 — $\displaystyle\int \sin^m x \cos^n x\,dx$ with both $m$ and $n$ even
Now neither function will surrender a clean differential, so the Pythagorean trick stalls. Switch to power reduction: replace $\sin^2$ or $\cos^2$ by its half-angle form to lower the exponents, repeating as needed.
Worked Example 16.2.3. Evaluate $\displaystyle\int \cos^2 x\,dx$ — the integral behind the average power of an AC circuit.
Use $\cos^2 x = \tfrac12(1 + \cos 2x)$:
$$\int \cos^2 x\,dx = \frac12 \int (1 + \cos 2x)\,dx = \frac{x}{2} + \frac{\sin 2x}{4} + C.$$
Worked Example 16.2.4. Evaluate $\displaystyle\int \sin^4 x\,dx$ — power reduction applied twice.
Start by squaring the half-angle identity:
$$\sin^4 x = (\sin^2 x)^2 = \left(\frac{1 - \cos 2x}{2}\right)^2 = \frac{1 - 2\cos 2x + \cos^2 2x}{4}.$$
The stubborn term is $\cos^2 2x$ — still an even power, so reduce it again with $\cos^2\theta = \tfrac12(1 + \cos 2\theta)$, here $\theta = 2x$:
$$\cos^2 2x = \frac{1 + \cos 4x}{2} \;\Longrightarrow\; \sin^4 x = \frac14\left(1 - 2\cos 2x + \frac{1 + \cos 4x}{2}\right) = \frac38 - \frac{\cos 2x}{2} + \frac{\cos 4x}{8}.$$
Now every term integrates by inspection:
$$\int \sin^4 x\,dx = \frac{3x}{8} - \frac{\sin 2x}{4} + \frac{\sin 4x}{32} + C.$$
Common Pitfall. Many students try $u = \cos x$ on $\int \sin^4 x\,dx$, hoping the Case-1 trick works. It does not: there is no spare $\sin x$ to become $du$ (the power is even), and forcing it produces a square root and a tangle. When both powers are even, only power reduction works. The tell is parity: odd power $\Rightarrow$ peel and substitute; both even $\Rightarrow$ half-angle.
Case 4 — $\displaystyle\int \tan^m x \sec^n x\,dx$
The tangent–secant family runs on two facts: $\dfrac{d}{dx}\tan x = \sec^2 x$ and $\dfrac{d}{dx}\sec x = \sec x \tan x$, together with the identity $\sec^2 x = 1 + \tan^2 x$. Two clean cases:
- $n$ even (a spare $\sec^2 x$ available): set aside $\sec^2 x$ for $du$, convert the rest with $\sec^2 x = 1 + \tan^2 x$, and substitute $u = \tan x$.
- $m$ odd (a spare $\sec x\tan x$ available): set aside $\sec x\tan x$ for $du$, convert the remaining even power of $\tan$ with $\tan^2 x = \sec^2 x - 1$, and substitute $u = \sec x$.
Worked Example 16.2.5. Evaluate $\displaystyle\int \tan^3 x \sec^4 x\,dx$.
Here $n = 4$ is even, so reserve a $\sec^2 x$ and rewrite the other $\sec^2 x = 1 + \tan^2 x$. Let $u = \tan x$, $du = \sec^2 x\,dx$:
$$\int \tan^3 x\,(1 + \tan^2 x)\,\sec^2 x\,dx = \int u^3(1 + u^2)\,du = \int (u^3 + u^5)\,du = \frac{u^4}{4} + \frac{u^6}{6} + C = \frac{\tan^4 x}{4} + \frac{\tan^6 x}{6} + C.$$
Historical Note. The lone secant integral $\int \sec x\,dx = \ln|\sec x + \tan x| + C$ has a startling pedigree. In the 1560s the cartographer Gerardus Mercator drew his famous map by a numerical table that, unbeknownst to him, summed to this integral; the closed form was conjectured by the mathematician Edward Wright (1599) and only proved decades later. Navigators were integrating the secant a century before Newton and Leibniz named calculus.
16.3 Products with Different Arguments
A different problem arises when the two trig factors have different frequencies, as in $\int \sin(3x)\cos(5x)\,dx$. The peel-and-substitute tricks fail because the arguments don't match. The fix is the product-to-sum identities, which trade a product for a sum that integrates term by term:
$$\sin A \cos B = \tfrac12\big[\sin(A - B) + \sin(A + B)\big],$$ $$\sin A \sin B = \tfrac12\big[\cos(A - B) - \cos(A + B)\big],$$ $$\cos A \cos B = \tfrac12\big[\cos(A - B) + \cos(A + B)\big].$$
Worked Example 16.3.1. Evaluate $\displaystyle\int \sin(3x)\cos(5x)\,dx$.
With $A = 3x$, $B = 5x$:
$$\sin(3x)\cos(5x) = \tfrac12\big[\sin(-2x) + \sin(8x)\big] = \tfrac12\big[-\sin(2x) + \sin(8x)\big].$$
Integrate each piece:
$$\int \sin(3x)\cos(5x)\,dx = \tfrac12\left[\frac{\cos 2x}{2} - \frac{\cos 8x}{8}\right] + C = \frac{\cos 2x}{4} - \frac{\cos 8x}{16} + C.$$
(A sympy check returns a trigonometrically equivalent form, $\tfrac{5}{16}\sin 3x\sin 5x + \tfrac{3}{16}\cos 3x\cos 5x$; the two differ only by a constant — confirmed below in §16.6.)
Real-World Application — Fourier analysis and orthogonality (signal processing, physics). These same identities are the mathematical bedrock of Fourier series, the tool that decomposes any periodic signal — an audio waveform, an EEG trace, a vibrating string — into pure sinusoids. The crucial fact is that over one full period, $\int_0^{2\pi} \sin(mx)\cos(nx)\,dx = 0$ whenever $m \neq n$, and likewise for $\sin\!\cdot\!\sin$ and $\cos\!\cdot\!\cos$ with $m\neq n$. Different frequencies are orthogonal: they don't "see" each other under integration. That orthogonality is exactly why you can isolate each frequency component of a signal independently, which is what an MP3 encoder and a spectrum analyzer do millions of times a second.
16.4 Trigonometric Substitution
Now to the technique this chapter is named for and that later chapters will keep referencing. When an integrand contains $\sqrt{a^2 - x^2}$, $\sqrt{a^2 + x^2}$, or $\sqrt{x^2 - a^2}$, no amount of $u$-substitution removes the radical — the derivative of what's inside isn't sitting outside. Trigonometric substitution sidesteps the problem entirely: replace $x$ by a trig function chosen so that a Pythagorean identity collapses the radical into a single trig term.
| Radical | Substitution | Identity used | $dx$ | radical becomes |
|---|---|---|---|---|
| $\sqrt{a^2 - x^2}$ | $x = a\sin\theta$ | $1 - \sin^2\theta = \cos^2\theta$ | $a\cos\theta\,d\theta$ | $a\cos\theta$ |
| $\sqrt{a^2 + x^2}$ | $x = a\tan\theta$ | $1 + \tan^2\theta = \sec^2\theta$ | $a\sec^2\theta\,d\theta$ | $a\sec\theta$ |
| $\sqrt{x^2 - a^2}$ | $x = a\sec\theta$ | $\sec^2\theta - 1 = \tan^2\theta$ | $a\sec\theta\tan\theta\,d\theta$ | $a\tan\theta$ |
Geometric Intuition. Each substitution is a right triangle in disguise. For $\sqrt{a^2 - x^2}$, draw a right triangle with hypotenuse $a$ and one leg $x$; then $\sin\theta = x/a$ and the other leg is $\sqrt{a^2 - x^2} = a\cos\theta$. For $\sqrt{a^2 + x^2}$, make $x$ and $a$ the two legs so the hypotenuse is $\sqrt{a^2+x^2}$ and $\tan\theta = x/a$. For $\sqrt{x^2 - a^2}$, make $x$ the hypotenuse and $a$ a leg so $\sec\theta = x/a$. You never have to memorize the back-substitution — just read the missing side off the triangle. Geometry and algebra, once again, are the same statement.
Worked Example 16.4.1 — The defining $\arcsin$ integral
Evaluate $\displaystyle\int \frac{dx}{\sqrt{4 - x^2}}$.
This is the $\sqrt{a^2 - x^2}$ form with $a = 2$. Let $x = 2\sin\theta$, so $dx = 2\cos\theta\,d\theta$ and $\sqrt{4 - x^2} = \sqrt{4 - 4\sin^2\theta} = 2|\cos\theta| = 2\cos\theta$ (taking $-\pi/2 \le \theta \le \pi/2$, where $\cos\theta \ge 0$). Then
$$\int \frac{dx}{\sqrt{4 - x^2}} = \int \frac{2\cos\theta}{2\cos\theta}\,d\theta = \int d\theta = \theta + C = \arcsin\!\frac{x}{2} + C.$$
(Back-substitution: $x = 2\sin\theta \Rightarrow \theta = \arcsin(x/2)$.) This confirms the general antiderivative
$$\int \frac{dx}{\sqrt{a^2 - x^2}} = \arcsin\!\frac{x}{a} + C,$$
worth memorizing — it is one of the few integrals where a purely algebraic integrand produces an inverse trig function.
Warning. The absolute value $\sqrt{4 - 4\sin^2\theta} = 2|\cos\theta|$ is not a pedantic decoration. It is legitimate to drop it to $2\cos\theta$ only because the standard range $-\pi/2 \le \theta \le \pi/2$ of $\arcsin$ keeps $\cos\theta \ge 0$. With $x = a\sec\theta$ for $\sqrt{x^2 - a^2}$, the corresponding $\sqrt{\tan^2\theta} = |\tan\theta|$ genuinely changes sign depending on whether $x > a$ or $x < -a$, and ignoring it produces wrong signs on half the domain. Always note your $\theta$-range before discarding an absolute value.
Worked Example 16.4.2 — A quarter circle, checked against geometry
Find the area under $y = \sqrt{4 - x^2}$ from $x = 0$ to $x = 2$. The curve is the upper half of the circle $x^2 + y^2 = 4$, so this region is exactly one quarter of a disk of radius $2$, and we expect the answer $\tfrac14\pi(2)^2 = \pi$.
$$A = \int_0^2 \sqrt{4 - x^2}\,dx.$$
Substitute $x = 2\sin\theta$, $dx = 2\cos\theta\,d\theta$, $\sqrt{4-x^2} = 2\cos\theta$. Convert the limits (cleaner than back-substituting): $x = 0 \Rightarrow \theta = 0$, and $x = 2 \Rightarrow \sin\theta = 1 \Rightarrow \theta = \pi/2$. Then
$$A = \int_0^{\pi/2} 2\cos\theta \cdot 2\cos\theta\,d\theta = 4\int_0^{\pi/2}\cos^2\theta\,d\theta.$$
By Worked Example 16.2.3, $\int \cos^2\theta\,d\theta = \tfrac{\theta}{2} + \tfrac{\sin 2\theta}{4}$, so $\int_0^{\pi/2}\cos^2\theta\,d\theta = \big[\tfrac{\theta}{2} + \tfrac{\sin 2\theta}{4}\big]_0^{\pi/2} = \tfrac{\pi}{4} + 0 = \tfrac{\pi}{4}$. Therefore
$$A = 4 \cdot \frac{\pi}{4} = \pi,$$
precisely the quarter-circle area. Trig substitution and elementary geometry shake hands.
Worked Example 16.4.3 — The $\sqrt{a^2 + x^2}$ case
Evaluate $\displaystyle\int \frac{dx}{\sqrt{x^2 + 9}}$.
This is the $\sqrt{a^2 + x^2}$ form with $a = 3$. Let $x = 3\tan\theta$, $dx = 3\sec^2\theta\,d\theta$, and $\sqrt{x^2 + 9} = \sqrt{9\sec^2\theta} = 3\sec\theta$. Then
$$\int \frac{dx}{\sqrt{x^2 + 9}} = \int \frac{3\sec^2\theta}{3\sec\theta}\,d\theta = \int \sec\theta\,d\theta = \ln|\sec\theta + \tan\theta| + C.$$
From the triangle (legs $x$ and $3$, hypotenuse $\sqrt{x^2+9}$): $\tan\theta = x/3$ and $\sec\theta = \sqrt{x^2+9}/3$. Back-substitute:
$$= \ln\left|\frac{\sqrt{x^2 + 9} + x}{3}\right| + C = \ln\big|x + \sqrt{x^2 + 9}\big| + C',$$
where the $-\ln 3$ has been absorbed into the new constant $C'$. This antiderivative is also $\sinh^{-1}(x/3) + C$ up to a constant — the inverse hyperbolic sine — a fact worth filing away but not needed here.
Worked Example 16.4.4 — The $\sqrt{x^2 - a^2}$ case
Evaluate $\displaystyle\int \frac{\sqrt{x^2 - 1}}{x}\,dx$.
This is the $\sqrt{x^2 - a^2}$ form with $a = 1$. Let $x = \sec\theta$, $dx = \sec\theta\tan\theta\,d\theta$, and $\sqrt{x^2 - 1} = \sqrt{\sec^2\theta - 1} = \tan\theta$ (on the range where $\tan\theta \ge 0$). Then
$$\int \frac{\tan\theta}{\sec\theta}\cdot \sec\theta\tan\theta\,d\theta = \int \tan^2\theta\,d\theta = \int (\sec^2\theta - 1)\,d\theta = \tan\theta - \theta + C.$$
Back-substitute via the triangle ($\sec\theta = x$, opposite leg $\sqrt{x^2-1}$): $\tan\theta = \sqrt{x^2 - 1}$ and $\theta = \operatorname{arcsec} x$. Hence
$$\int \frac{\sqrt{x^2 - 1}}{x}\,dx = \sqrt{x^2 - 1} - \operatorname{arcsec} x + C.$$
Common Pitfall. After integrating in $\theta$, students often forget to convert back to $x$, leaving an answer like "$\tan\theta - \theta + C$." That is not an answer to the original problem, which was posed in $x$. Always finish with the triangle: rebuild every trig function of $\theta$ as an algebraic expression in $x$. The substitution is a round trip — going in and coming back out.
Real-World Application — Arc length and the ellipse (engineering, astronomy). Trig substitution is the gateway to arc-length integrals (Chapter 18), which contain $\sqrt{1 + (f')^2}$. For a parabola or a catenary the radical is exactly the $\sqrt{a^2 + x^2}$ form and trig substitution finishes the job. (The ellipse is the famous exception: its arc length produces an elliptic integral with no elementary antiderivative — historically the very problem that forced mathematicians toward the numerical methods of §16.5, and a reason planetary-orbit computations were so hard before computers.)
16.5 Partial Fractions
A rational function is a ratio of polynomials $p(x)/q(x)$. Partial fraction decomposition rewrites it as a sum of simpler fractions — each over a single factor of the denominator — that you already know how to integrate. It is high-school algebra (adding fractions over a common denominator) run backward.
The Strategy
- If $\deg p \ge \deg q$, divide first. Polynomial long division writes $p/q = (\text{polynomial}) + (\text{proper rational function})$, where the remainder now has $\deg(\text{numerator}) < \deg(\text{denominator})$. Decomposition applies only to proper fractions.
- Factor $q(x)$ completely into linear factors $(x - r)$ and irreducible quadratic factors $(x^2 + bx + c)$ (those with no real roots, i.e. $b^2 - 4c < 0$).
- Write the decomposition template: - each linear power $(x - r)^k$ contributes $\dfrac{A_1}{x - r} + \dfrac{A_2}{(x-r)^2} + \cdots + \dfrac{A_k}{(x-r)^k}$; - each irreducible quadratic power $(x^2 + bx + c)^k$ contributes $\dfrac{B_1 x + C_1}{x^2 + bx + c} + \cdots + \dfrac{B_k x + C_k}{(x^2 + bx + c)^k}$.
- Solve for the coefficients by clearing denominators, then either substituting convenient values of $x$ (best for linear factors) or matching coefficients of like powers (best for quadratics).
- Integrate each piece with the standard antiderivatives: - $\displaystyle\int \frac{dx}{x - r} = \ln|x - r| + C$; - $\displaystyle\int \frac{dx}{(x - r)^k} = -\frac{1}{(k-1)(x-r)^{k-1}} + C$ for $k > 1$; - quadratic terms split into a $\ln$ piece (from the $x$ in the numerator) and an $\arctan$ piece (from the constant).
Worked Example 16.5.1 — Distinct linear factors
Evaluate $\displaystyle\int \frac{dx}{x^2 - 1}$.
Factor $x^2 - 1 = (x-1)(x+1)$ and set up the template:
$$\frac{1}{(x-1)(x+1)} = \frac{A}{x-1} + \frac{B}{x+1}.$$
Clear denominators: $1 = A(x+1) + B(x-1)$. Now use the cover-up trick — substitute the root that kills one term:
$$x = 1:\quad 1 = 2A \Rightarrow A = \tfrac12; \qquad x = -1:\quad 1 = -2B \Rightarrow B = -\tfrac12.$$
Therefore
$$\int \frac{dx}{x^2 - 1} = \int\left(\frac{1/2}{x-1} - \frac{1/2}{x+1}\right)dx = \frac12\ln|x-1| - \frac12\ln|x+1| + C = \frac12\ln\left|\frac{x-1}{x+1}\right| + C.$$
Check Your Understanding. Set up (do not solve) the partial-fraction template for $\dfrac{3x + 5}{x(x-2)(x+4)}$.
Answer
Three distinct linear factors, so three single terms: $\dfrac{3x+5}{x(x-2)(x+4)} = \dfrac{A}{x} + \dfrac{B}{x-2} + \dfrac{C}{x+4}$. Each linear factor gets exactly one constant over it because none is repeated.
Worked Example 16.5.2 — A repeated linear factor
Evaluate $\displaystyle\int \frac{x^2}{(x-1)^3}\,dx$.
The factor $(x-1)$ appears to the third power, so the template carries one term for each power up to 3:
$$\frac{x^2}{(x-1)^3} = \frac{A}{x-1} + \frac{B}{(x-1)^2} + \frac{C}{(x-1)^3}.$$
Clear denominators: $x^2 = A(x-1)^2 + B(x-1) + C$. Expanding,
$$x^2 = A x^2 + (B - 2A)x + (A - B + C).$$
Match coefficients: $A = 1$ (from $x^2$); $B - 2A = 0 \Rightarrow B = 2$ (from $x$); $A - B + C = 0 \Rightarrow C = 1$ (constant). Integrate term by term:
$$\int\left[\frac{1}{x-1} + \frac{2}{(x-1)^2} + \frac{1}{(x-1)^3}\right]dx = \ln|x-1| - \frac{2}{x-1} - \frac{1}{2(x-1)^2} + C.$$
Common Pitfall. With a repeated factor $(x-1)^3$, students frequently write only $\dfrac{A}{(x-1)^3}$ and stop. That template is too small — it cannot represent a general numerator of degree 2 over $(x-1)^3$, and your coefficient equations will be inconsistent (no solution). The rule is firm: a factor raised to power $k$ demands all $k$ terms, from $(x-1)^1$ up through $(x-1)^k$.
Worked Example 16.5.3 — An irreducible quadratic factor
Evaluate $\displaystyle\int \frac{dx}{x(x^2 + 1)}$.
The quadratic $x^2 + 1$ has no real roots ($b^2 - 4c = -4 < 0$), so it is irreducible and gets a linear numerator:
$$\frac{1}{x(x^2 + 1)} = \frac{A}{x} + \frac{Bx + C}{x^2 + 1}.$$
Clear denominators: $1 = A(x^2 + 1) + (Bx + C)x = (A + B)x^2 + Cx + A$. Matching coefficients: $A = 1$ (constant), $C = 0$ ($x$ term), $A + B = 0 \Rightarrow B = -1$ ($x^2$ term). So
$$\int \frac{dx}{x(x^2 + 1)} = \int\left(\frac{1}{x} - \frac{x}{x^2 + 1}\right)dx = \ln|x| - \frac12\ln(x^2 + 1) + C.$$
(The second integral used $u = x^2 + 1$, $du = 2x\,dx$ — a $u$-substitution from Chapter 15. Had the numerator left a leftover constant, that constant over $x^2 + 1$ would have integrated to an $\arctan$.)
Worked Example 16.5.4 — Improper fraction: divide first
Evaluate $\displaystyle\int \frac{x^3 + 1}{x^2 - 4}\,dx$.
The numerator has degree $3 \ge 2$, so begin with long division. Dividing $x^3 + 1$ by $x^2 - 4$ gives quotient $x$ and remainder $4x + 1$ (verified in §16.6 with sympy):
$$\frac{x^3 + 1}{x^2 - 4} = x + \frac{4x + 1}{x^2 - 4}.$$
Now decompose the proper remainder over $x^2 - 4 = (x-2)(x+2)$:
$$\frac{4x + 1}{(x-2)(x+2)} = \frac{A}{x-2} + \frac{B}{x+2}, \qquad 4x + 1 = A(x+2) + B(x-2).$$
Cover-up: $x = 2 \Rightarrow 9 = 4A \Rightarrow A = \tfrac94$; $x = -2 \Rightarrow -7 = -4B \Rightarrow B = \tfrac74$. Assemble everything:
$$\int \frac{x^3 + 1}{x^2 - 4}\,dx = \int\left[x + \frac{9/4}{x-2} + \frac{7/4}{x+2}\right]dx = \frac{x^2}{2} + \frac94\ln|x-2| + \frac74\ln|x+2| + C.$$
Real-World Application — Logistic growth and chemical kinetics (biology, chemistry). Partial fractions are not a parlor trick; they solve one of the most important differential equations in science. The logistic model $\frac{dP}{dt} = kP(1 - P/M)$ — population growth with a carrying capacity $M$, which you will meet fully in Chapter 19 — separates to $\int \frac{dP}{P(1 - P/M)} = \int k\,dt$. The left integrand is a rational function in $P$; partial fractions split it into $\frac{1}{P}$ and $\frac{1/M}{1 - P/M}$ pieces, and integrating yields the famous S-shaped logistic curve. The identical algebra solves second-order chemical reaction rates. Without partial fractions, these closed-form solutions would be out of reach.
16.6 Numerical Integration
Chapter 14 delivered a sobering theorem (Liouville's): most integrands have no elementary antiderivative. No identity, substitution, or decomposition will ever produce a formula for $\int e^{-x^2}\,dx$, $\int \sin(x^2)\,dx$, or $\int \frac{\sin x}{x}\,dx$. When the analytic toolkit runs out — or when the integrand is given only as a table of measured values — we approximate the definite integral numerically. Two methods cover almost everything you will need.
The Trapezoidal Rule
Partition $[a, b]$ into $n$ equal subintervals of width $h = (b - a)/n$, with nodes $x_0 = a,\, x_1,\, \ldots,\, x_n = b$. Instead of capping each strip with a flat rectangle (a crude Riemann sum), cap it with a straight line joining consecutive points — a trapezoid. Summing the trapezoid areas and collecting common terms gives
$$T_n = \frac{h}{2}\Big[f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n)\Big].$$
Interior nodes are weighted $2$ (each is shared by two trapezoids); the endpoints, belonging to one trapezoid each, are weighted $1$.
Geometric Intuition. A rectangle ignores the slope of $f$ across the strip; a trapezoid honors it by connecting the two endpoint heights with a straight chord. Where $f$ is concave up, the chord lies above the curve and the trapezoid overestimates; where $f$ is concave down, it underestimates. That is precisely why the error depends on $f''$ (concavity) — flatter functions integrate more accurately.
Error bound (trapezoidal).
$$|I - T_n| \le \frac{(b - a)^3}{12\,n^2}\,\max_{[a,b]}|f''|.$$
The error falls like $1/n^2$: double $n$ and the error drops by a factor of $4$.
Simpson's Rule
Do better by fitting a parabola through each consecutive triple of points instead of a line through each pair. This requires $n$ to be even (the nodes pair up into arcs). Collecting terms,
$$S_n = \frac{h}{3}\Big[f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + \cdots + 4f(x_{n-1}) + f(x_n)\Big].$$
The weight pattern is $1, 4, 2, 4, 2, \ldots, 4, 1$: endpoints $1$, odd-indexed nodes $4$, even-indexed interior nodes $2$. (Memory aid for the leading factor: $\tfrac{h}{3}$, not $\tfrac{h}{2}$.)
Error bound (Simpson's).
$$|I - S_n| \le \frac{(b - a)^5}{180\,n^4}\,\max_{[a,b]}\big|f^{(4)}\big|.$$
The error falls like $1/n^4$: double $n$ and the error drops by a factor of $16$. Remarkably, Simpson's rule is exact for any cubic (its $f^{(4)} = 0$), even though it only fits parabolas — a happy cancellation that makes it the default low-order method in practice.
Math Major Sidebar — Why Simpson beats its own degree. You'd expect a rule built from degree-2 parabolas to be exact only up to degree 2. Yet Simpson's rule integrates cubics exactly. The reason is symmetry: over a symmetric pair of subintervals $[x_{i-1}, x_{i+1}]$, the error of fitting a parabola to $x^3$ is an odd function about the midpoint, so its contributions on the two halves cancel exactly. This "degree of exactness $= 3$" is one order higher than the interpolation degree — the prototype of the deeper phenomenon (Gaussian quadrature, below) where clever node placement buys extra orders of accuracy for free.
Worked Example 16.6.1 — Both methods on $\displaystyle\int_0^1 e^{-x^2}\,dx$
This is the area under the (unnormalized) bell curve — the Area Under the Normal Curve anchor example from Chapter 13 — and it has no elementary antiderivative, so numerical methods are required, not merely convenient.
# Compare trapezoidal and Simpson's rules against high-precision quadrature
# on the integral of e^{-x^2} from 0 to 1 (no elementary antiderivative).
import numpy as np
from scipy.integrate import quad, trapezoid, simpson
f = lambda x: np.exp(-x**2)
# Adaptive quadrature gives a near-exact reference value
exact, _ = quad(f, 0, 1)
print(f"quad (reference): {exact:.10f}") # 0.7468241328
# Both rules use the same 11 nodes (n = 10 subintervals)
x = np.linspace(0, 1, 11)
y = f(x)
trap = trapezoid(y, x)
simp = simpson(y, x=x)
print(f"Trapezoid n=10 : {trap:.10f}, error {abs(trap - exact):.2e}")
print(f"Simpson n=10 : {simp:.10f}, error {abs(simp - exact):.2e}")
# Output:
# quad (reference): 0.7468241328
# Trapezoid n=10 : 0.7462107961, error 6.13e-04
# Simpson n=10 : 0.7468249483, error 8.15e-07
With the same ten subintervals, Simpson's rule is roughly a thousand times more accurate than the trapezoidal rule — about seven correct digits versus three. The error bounds explain why: $1/n^4$ versus $1/n^2$, plus Simpson's exactness on cubics.
Computational Note. In real production code almost nobody hand-codes these rules.
scipy.integrate.quadimplements adaptive quadrature: it samples the integrand more densely where the function wiggles and sparsely where it is smooth, returning both an estimate and a rigorous error bound (the second value it returns). The same engine lives inside Mathematica, MATLAB, and R. Trapezoidal and Simpson's rules remain essential to understand — and indispensable when your data is a fixed table of values you cannot resample — but for a formula you can evaluate anywhere, reach forquad.
When to Reach for Numerical Methods
- No elementary antiderivative — $\int e^{-x^2}\,dx$, $\int \sin(x^2)\,dx$, $\int \frac{\sin x}{x}\,dx$, elliptic integrals.
- The integrand is data, not a formula — sensor readings, experimental measurements, a column in a spreadsheet. You have values, not a closed form, so trapezoid/Simpson on the sample points is the only option.
- A closed form exists but is hideous — sometimes a number is all you want, and ten lines of partial-fraction algebra to get it is not worth the time.
Warning. Numerical integration silently misbehaves near singularities and over infinite intervals. Feeding $\int_0^1 \frac{1}{\sqrt{x}}\,dx$ to a naive trapezoidal sum returns garbage because $f(0)$ is infinite, and the methods above assume a finite interval with a bounded integrand. Integrals over infinite intervals or with infinite integrands are improper integrals — their definition, convergence tests, and the right way to handle them numerically are the subject of Chapter 17. Do not point trapezoid or Simpson at such an integral without first reading that chapter.
A Glimpse Beyond
Two methods you may meet later in scientific computing:
- Gaussian quadrature — instead of equally spaced nodes, choose the nodes and weights optimally; an $n$-point Gaussian rule integrates every polynomial up to degree $2n - 1$ exactly. It is the workhorse of finite-element analysis.
- Monte Carlo integration — estimate the integral by averaging the integrand at random points. Hopelessly inefficient in one dimension, it becomes the only practical method in the high-dimensional integrals of statistical physics and Bayesian statistics, where grids of nodes explode combinatorially.
These belong to a numerical-analysis course; for this book, trapezoidal and Simpson's rules — and scipy.integrate.quad for production — are enough.
16.7 The Master Strategy
You now hold every major integration technique. Faced with an unfamiliar integral, run down this decision tree:
- Antiderivative table? Check the basic forms (Chapter 12) and the results memorized in Chapter 15. Many integrals are one lookup away.
- $u$-substitution? Look for a composite function whose inner derivative appears (up to a constant) as a factor. (Chapter 15.)
- Integration by parts? A product of two unlike function types — polynomial × exponential, log × polynomial — calls for parts, with the LIATE rule guiding the choice of $u$. (Chapter 15.)
- Powers/products of trig functions? Apply the parity and power-reduction strategy of §16.2–16.3.
- A radical $\sqrt{a^2 - x^2}$, $\sqrt{a^2 + x^2}$, or $\sqrt{x^2 - a^2}$? Trigonometric substitution (§16.4).
- A rational function $p(x)/q(x)$? Partial fractions, dividing first if improper (§16.5).
- None of the above (or no elementary antiderivative)? Numerical integration (§16.6).
The Key Insight. Integration is genuinely harder than differentiation, and the reason is deep, not a gap in your training. Every elementary function differentiates to another elementary function — the rules always close. Integration does not: Liouville (1830s) and later Risch proved that functions like $e^{-x^2}$ have no elementary antiderivative at all. So when an integral resists every technique above, you are not failing — you may have hit one of the provably impossible cases, and numerical integration is the mathematically correct response, not a surrender.
16.8 Symbolic and Numerical Computation
Per the book's three-tier pattern, verify the chapter's hand computations with sympy (symbolic) and scipy (numerical). Notice that the machine sometimes returns an algebraically equivalent form rather than your exact expression — confirming agreement is itself a useful skill.
# Verify the chapter's worked examples symbolically (sympy) and numerically (scipy).
import sympy as sp
import numpy as np
from scipy.integrate import quad
x = sp.symbols('x')
# --- Trigonometric integrals (16.2) ---
print(sp.integrate(sp.sin(x)**3 * sp.cos(x)**2, x)) # cos^5/5 - cos^3/3 (matches 16.2.1)
print(sp.integrate(sp.cos(x)**5, x)) # 16.2.2
print(sp.integrate(sp.cos(x)**2, x)) # x/2 + sin(x)cos(x)/2 (equiv. to 16.2.3)
# --- Product-to-sum (16.3): sympy returns an equivalent form ---
print(sp.simplify(sp.integrate(sp.sin(3*x)*sp.cos(5*x), x)
- (sp.cos(2*x)/4 - sp.cos(8*x)/16))) # 0 -> answers agree up to a constant
# --- Trig substitution (16.4) ---
print(sp.integrate(1/sp.sqrt(4 - x**2), x)) # asin(x/2) (16.4.1)
print(sp.integrate(sp.sqrt(4 - x**2), (x, 0, 2))) # pi (16.4.2)
# --- Partial fractions (16.5) ---
print(sp.apart(1/(x**2 - 1))) # -1/(2(x+1)) + 1/(2(x-1)) (16.5.1)
print(sp.div(x**3 + 1, x**2 - 4)) # (x, 4*x + 1) -> quotient x, remainder 4x+1 (16.5.4)
# --- Numerical (16.6) ---
val, err = quad(lambda t: np.exp(-t**2), 0, 1)
print(f"numerical: {val:.10f}, error estimate {err:.2e}") # 0.7468241328
# Output (abbreviated):
# cos(x)**5/5 - cos(x)**3/3
# sin(x)**5/5 - 2*sin(x)**3/3 + sin(x)
# x/2 + sin(x)*cos(x)/2
# 0
# asin(x/2)
# pi
# -1/(2*(x + 1)) + 1/(2*(x - 1))
# (x, 4*x + 1)
# numerical: 0.7468241328, error estimate 8.29e-15
The sp.simplify(... ) -> 0 line is the lesson worth absorbing: sympy's antiderivative for $\int \sin 3x\cos 5x\,dx$ looks nothing like the $\tfrac{\cos 2x}{4} - \tfrac{\cos 8x}{16}$ you derived, yet their difference simplifies to zero. Two antiderivatives that differ by a constant are equally correct (Chapter 14) — a fact you must internalize before you trust any computer algebra system.
Add to Your Modeling Portfolio. This chapter contributes the technique that lets you integrate the closed-form part of your model and numerically integrate the rest. Add one such computation to your portfolio. Biology: use partial fractions to integrate the logistic rate $\frac{dP}{P(1 - P/M)}$ by hand, deriving the S-curve you will solve fully in Chapter 19; then numerically integrate a real population time series given only as data points. Economics: numerically integrate a marginal-cost curve supplied as a table of production data to recover total cost, comparing trapezoidal and Simpson estimates. Physics: use trig substitution to compute the arc length of a parabolic trajectory (a $\sqrt{a^2 + x^2}$ integral), then numerically integrate the pendulum period integral, which is elliptic and has no closed form. Data Science: numerically integrate $e^{-x^2}$ to tabulate values of the error function $\operatorname{erf}$, the backbone of the normal-distribution CDF you have been building since Chapter 13.
16.9 Summary
The complete integration toolkit, with the trigger for each tool:
| Technique | Use it when… |
|---|---|
| Basic antiderivative table | the form is a direct lookup |
| $u$-substitution (Ch. 15) | a composite function appears with its inner derivative |
| Integration by parts (Ch. 15) | the integrand is a product of unlike function types (LIATE) |
| Trig identities & powers (§16.2–16.3) | powers/products of $\sin,\cos$ or $\tan,\sec$ |
| Trig substitution (§16.4) | a radical $\sqrt{a^2 - x^2}$, $\sqrt{a^2 + x^2}$, or $\sqrt{x^2 - a^2}$ |
| Partial fractions (§16.5) | a rational function $p(x)/q(x)$ |
| Trapezoidal / Simpson's rule (§16.6) | no elementary antiderivative, or the integrand is data |
scipy.integrate.quad |
a formula you can evaluate, in production code |
Three habits make these techniques stick: memorize the standard antiderivatives (the $\arcsin$, $\arctan$, and $\ln$ forms recur constantly), drill pattern recognition until the right tool is obvious in seconds, and verify with sympy while being ready to reconcile equivalent-but-different forms. For everything the analytic toolkit cannot reach, numerical integration always works.
Looking Ahead
The integrals in this chapter all lived on finite intervals with bounded integrands. Chapter 17 lifts both restrictions, defining improper integrals over infinite intervals (like $\int_1^\infty \frac{dx}{x^2}$) and with infinite integrands (like $\int_0^1 \frac{dx}{\sqrt{x}}$), along with the convergence tests that decide when such an integral has a finite value at all. Chapter 18 turns the entire integration toolkit loose on geometry and physics — areas between curves, volumes of revolution, arc length, surface area, and work. Chapter 19 closes Part III with differential equations, where the partial-fraction technique you just learned reappears to solve the logistic model. From here on, "evaluate the integral" is a step inside a larger problem, never the whole problem.
Continue to: Exercises · Quiz · Case Study 1 · Case Study 2 · Key Takeaways · Further Reading