TExcelTAD
Home › Calculus in Depth › Strategy for Integration

Strategy for Integration

Differentiation is an algorithm: apply the rules and you always get an answer. Integration is a search: you must recognise which technique fits, and sometimes none does. This lesson organises the techniques of this chapter into a strategy, shows how to recognise each type, and explains which integrals cannot be done in elementary terms at all, and what to do then.

The toolbox so far

Technique Recognise it by Lesson
table + linearity sum of basic functions Antiderivatives
substitution a composite f(g(x))f(g(x)) times (a multiple of) g′(x)g'(x) Substitution
integration by parts product of unlike types: x⋅exx \cdot e^x, x2⋅sin⁡xx^2 \cdot \sin x, ln⁡x\ln x, tan⁡−1x\tan^{-1} x Parts
trig integrals powers of sin⁡\sin/cos⁡\cos or tan⁡\tan/sec⁡\sec Trig Integrals
trig substitution a2±x2\sqrt{a^2 \pm x^2}, x2−a2\sqrt{x^2 - a^2} Trig Substitution
partial fractions rational function P(x)/Q(x)P(x)/Q(x) Partial Fractions
rationalising substitution g(x)n\sqrt[n]{g(x)} with linear gg, rational in sin⁡\sin, cos⁡\cos Partial Fractions

A four-step strategy

  1. Simplify the integrand. Expand, cancel, use identities. ∫sin⁡xcos⁡x dx=12∫sin⁡2x dx\int \sin x \cos x\,dx = \frac{1}{2}\int \sin 2x\,dx; ∫(1+x)2 dx\int (1 + \sqrt{x})^2\,dx expands to powers; ∫tan⁡2x dx=∫(sec⁡2x−1) dx\int \tan^2 x\,dx = \int (\sec^2 x - 1)\,dx.
  2. Look for an obvious substitution. Is part of the integrand (up to a constant) the derivative of another part? ∫xx2+1 dx\int \frac{x}{x^2 + 1}\,dx: u=x2+1u = x^2 + 1.
  3. Classify by form. Rational → partial fractions. Product of a polynomial and a transcendental function → parts. Trig powers → trig integrals. Radical of a quadratic → trig substitution (after completing the square).
  4. Try again. Manipulate: try a different substitution (even an unusual one), parts with dv=dxdv = dx, multiply by 1 in a clever form (sec⁡x+tan⁡xsec⁡x+tan⁡x\frac{\sec x + \tan x}{\sec x + \tan x}), relate the integral to one you have already done, or combine several methods.

Sometimes one problem needs several steps. ∫ex dx\int e^{\sqrt{x}}\,dx: substitute u=xu = \sqrt{x} (x=u2x = u^2, dx=2u dudx = 2u\,du) to get 2∫ueu du2\int u e^u\,du, then parts: 2eu(u−1)=2ex(x−1)+C2e^u(u - 1) = 2e^{\sqrt{x}}(\sqrt{x} - 1) + C.

How a CAS follows the same strategy

SymPy's manualintegrate module imitates the hand strategy: it tries a list of rules (table lookups, substitutions, parts, trig rules, partial fractions) and records which one it used. Asking for the steps shows the classification:

python · try it yourself
import sympy as sp
from sympy.integrals.manualintegrate import integral_steps

x = sp.symbols('x')
cases = [x * sp.exp(x**2), x * sp.exp(x), sp.sin(x)**3, sp.sqrt(4 - x**2),
         1 / (x**2 + 3*x + 2), sp.log(x)]
for f in cases:
    rule = type(integral_steps(f, x)).__name__
    print(f"{str(f):18} -> {rule:22} -> {sp.integrate(f, x, manual=True)}")
x*exp(x**2)        -> AlternativeRule        -> exp(x**2)/2
x*exp(x)           -> PartsRule              -> x*exp(x) - exp(x)
sin(x)**3          -> RewriteRule            -> cos(x)**3/3 - cos(x)
sqrt(4 - x**2)     -> SqrtQuadraticRule      -> x*sqrt(4 - x**2)/2 + 2*asin(x/2)
1/(x**2 + 3*x + 2) -> URule                  -> log(2*x + 2) - log(2*x + 4)
log(x)             -> PartsRule              -> x*log(x) - x

An AlternativeRule means SymPy found several workable approaches; a RewriteRule means it first rewrote the integrand (step 1 of our strategy, here sin⁡3x=(1−cos⁡2x)sin⁡x\sin^3 x = (1 - \cos^2 x) \sin x); URule is a substitution, here applied after splitting the rational function; SqrtQuadraticRule handles roots of quadratics, the job of trig substitution. Answers such as log(2x + 2) − log(2x + 4) differ from the textbook ln⁡∣x+1∣−ln⁡∣x+2∣\ln\lvert x + 1 \rvert - \ln\lvert x + 2 \rvert only by a constant.

Not every integral is elementary

An elementary function is built from polynomials, exponentials, logarithms, trig and inverse trig functions by arithmetic and composition. Every continuous function has an antiderivative (FTC Part 1), but often it is not elementary. Liouville's theorem (1830s) gives a precise criterion, and from it one can prove that these have no elementary antiderivative:

∫e−x2 dx∫sin⁡xx dx∫1ln⁡x dx∫1+x3 dx∫sin⁡(x2) dx∫exx dx\int e^{-x^2}\,dx \qquad \int \frac{\sin x}{x}\,dx \qquad \int \frac{1}{\ln x}\,dx \qquad \int \sqrt{1 + x^3}\,dx \qquad \int \sin(x^2)\,dx \qquad \int \frac{e^x}{x}\,dx

No amount of cleverness will find formulas for them. They define special functions instead, which a CAS reports by name:

python · try it yourself
import sympy as sp

x = sp.symbols('x', positive=True)
for f in [sp.exp(-x**2), sp.sin(x) / x, 1 / sp.log(x), sp.sin(x**2), sp.exp(x) / x]:
    print(f"∫ {str(f):12} dx = {sp.integrate(f, x)}")
∫ exp(-x**2)   dx = sqrt(pi)*erf(x)/2
∫ sin(x)/x     dx = Si(x)
∫ 1/log(x)     dx = li(x)
∫ sin(x**2)    dx = 3*sqrt(2)*sqrt(pi)*fresnels(sqrt(2)*x/sqrt(pi))*gamma(3/4)/(8*gamma(7/4))
∫ exp(x)/x     dx = Ei(x)

erf is the error function (normal-distribution probabilities), Si the sine integral (signal processing, antenna theory), li the logarithmic integral (counting primes: li(x) is the best simple estimate of how many primes lie below xx), fresnels a Fresnel integral (optics, clothoid road curves; the gamma(…) factors are just constants), and Ei the exponential integral.

When there is no formula: go numerical

For definite integrals, a non-elementary antiderivative is no obstacle. Numerical quadrature (Approximate Integration) gives the value to near machine precision:

python · try it yourself
import math
from scipy.integrate import quad
from scipy.special import sici

val, err = quad(lambda x: math.sin(x) / x if x else 1.0, 0, 10)
print(f"∫_0^10 sin x / x dx = {val:.12f}  (quad, estimated error {err:.1e})")
print(f"Si(10) from scipy.special   = {sici(10)[0]:.12f}")
val, _ = quad(lambda x: math.sqrt(1 + x**3), 0, 2)
print(f"∫_0^2 √(1 + x³) dx = {val:.10f}")
∫_0^10 sin x / x dx = 1.658347594219  (quad, estimated error 2.9e-14)
Si(10) from scipy.special   = 1.658347594219
∫_0^2 √(1 + x³) dx = 3.2413092632

In software

  • Symbolic integration is a search problem. CAS integrators (SymPy, Mathematica, Maple) combine heuristic rule-based search like the strategy above with complete decision procedures (the Risch algorithm) for elementary integrands. Researchers have even trained neural networks to propose antiderivatives, which are then checked by differentiation, the same "verify by differentiating" habit.
  • Know when to stop. In engineering code, a numerical integral is usually the right answer: faster to write, robust, and as accurate as you need. Reach for a closed form when you need it many times, need derivatives with respect to parameters, or want insight.
  • Special-function libraries (scipy.special, Boost.Math, Cephes) are the industrial answer to non-elementary integrals.

Exercises

Exercise 1: Classify

Name the technique you would try first for each: (a) ∫x2ex3 dx\int x^2 e^{x^3}\,dx, (b) ∫x2ex dx\int x^2 e^x\,dx, (c) ∫dxx2−5x+6\int \frac{dx}{x^2 - 5x + 6}, (d) ∫dx9+x2\int \frac{dx}{\sqrt{9 + x^2}}.

Answer

(a) substitution u=x3u = x^3; (b) parts (twice); (c) partial fractions; (d) trig substitution x=3tan⁡θx = 3\tan\theta (or x=3sinh⁡tx = 3\sinh t).

Solution

(a) x2x^2 is (up to 13\frac{1}{3}) the derivative of the inner x3x^3. (b) A polynomial times an exponential. (c) x2−5x+6=(x−2)(x−3)x^2 - 5x + 6 = (x - 2)(x - 3). (d) A root of a2+x2a^2 + x^2.

Exercise 2: Two techniques

Compute ∫sin⁡(x) dx\int \sin(\sqrt{x})\,dx.

Answer

2sin⁡x−2xcos⁡x+C2\sin\sqrt{x} - 2\sqrt{x}\cos\sqrt{x} + C.

Solution
u=x, x=u2, dx=2u du:∫2usin⁡u duparts (u-part=u, dv=sin⁡u du):2(−ucos⁡u+sin⁡u)+C\begin{aligned} &u = \sqrt{x},\ x = u^2,\ dx = 2u\,du: && \int 2u \sin u\,du \\ &\text{parts } (u\text{-part} = u,\ dv = \sin u\,du): && 2(-u \cos u + \sin u) + C \end{aligned}
python · try it yourself
import sympy as sp
x = sp.symbols('x', positive=True)
F = 2 * sp.sin(sp.sqrt(x)) - 2 * sp.sqrt(x) * sp.cos(sp.sqrt(x))
print(sp.simplify(sp.diff(F, x) - sp.sin(sp.sqrt(x))))
0

Exercise 3: Simplify first

Compute ∫1−sin⁡xcos⁡2x dx\int \frac{1 - \sin x}{\cos^2 x}\,dx.

Answer

tan⁡x−sec⁡x+C\tan x - \sec x + C.

Solution

Split: ∫sec⁡2x dx−∫sin⁡xcos⁡2x dx=tan⁡x−∫sec⁡xtan⁡x dx=tan⁡x−sec⁡x+C\int \sec^2 x\,dx - \int \frac{\sin x}{\cos^2 x}\,dx = \tan x - \int \sec x \tan x\,dx = \tan x - \sec x + C.

Exercise 4: Elementary or not?

Which of these has an elementary antiderivative: ex2e^{x^2}, x⋅ex2x \cdot e^{x^2}, ex2x2\frac{e^{x^2}}{x^2}?

Answer

Only x⋅ex2x \cdot e^{x^2} (antiderivative 12ex2\frac{1}{2}e^{x^2}).

Solution

xex2x e^{x^2} is a substitution with u=x2u = x^2. The other two are not elementary (∫ex2 dx\int e^{x^2}\,dx is the imaginary error function, erfi, up to a constant; parts on the third leads back to ∫ex2 dx\int e^{x^2}\,dx).

python · try it yourself
import sympy as sp
x = sp.symbols('x', positive=True)
for f in [sp.exp(x**2), x * sp.exp(x**2), sp.exp(x**2) / x**2]:
    print(f, "->", sp.integrate(f, x))
exp(x**2) -> sqrt(pi)*erfi(x)/2
x*exp(x**2) -> exp(x**2)/2
exp(x**2)/x**2 -> sqrt(pi)*erfi(x) - exp(x**2)/x

Test yourself

Which integral has no elementary antiderivative?

  1. ∫e−x2 dx\int e^{-x^2}\,dx
  2. ∫xe−x2 dx\int x e^{-x^2}\,dx
  3. ∫e−2x dx\int e^{-2x}\,dx
  4. ∫x2e−x dx\int x^2 e^{-x}\,dx

First step of the strategy for ∫(x2+2)2x dx\int \frac{(x^2 + 2)^2}{x}\,dx?

  1. Partial fractions
  2. Trig substitution
  3. Parts
  4. Expand and simplify: x3+4x+4/xx^3 + 4x + 4/x

A CAS returns erf⁡(x)\operatorname{erf}(x) for an integral. What does that mean?

  1. The integral diverges
  2. The antiderivative is a special (non-elementary) function, which can still be evaluated numerically
  3. The CAS failed
  4. The answer is 0