TExcelTAD
Home › Calculus in Depth › The Substitution Rule

The Substitution Rule

The chain rule is the most used rule of differentiation, and the Substitution Rule is the chain rule run backwards. It turns integrals like ∫2x⋅cos⁡(x2) dx\int 2x \cdot \cos(x^2)\,dx into table integrals by renaming the "inside" of a composition. This lesson proves the rule for indefinite and definite integrals, shows how to choose uu, and proves the symmetry shortcuts for even and odd functions. The survey version is Substitution.

The rule

Substitution Rule. If u=g(x)u = g(x) is differentiable with range an interval II and ff is continuous on II, then

∫f(g(x))⋅g′(x) dx=∫f(u) du\int f(g(x)) \cdot g'(x)\,dx = \int f(u)\,du.

Proof. Let FF be an antiderivative of ff (it exists by FTC Part 1). The chain rule gives ddxF(g(x))=F′(g(x))⋅g′(x)=f(g(x))⋅g′(x)\frac{d}{dx} F(g(x)) = F'(g(x)) \cdot g'(x) = f(g(x)) \cdot g'(x). So F(g(x))+CF(g(x)) + C is the left side; it is also F(u)+CF(u) + C with u=g(x)u = g(x), the right side. ∎

The notation du=g′(x) dxdu = g'(x)\,dx is bookkeeping: it reminds you that the factor g′(x)g'(x) must be present (up to a constant) before you substitute.

How to choose u

Look for a composite f(g(x))f(g(x)) whose inner derivative g′(x)g'(x) also appears as a factor.

Integral uu dudu Result
∫2xcos⁡(x2) dx\int 2x \cos(x^2)\,dx x2x^2 2x dx2x\,dx sin⁡(x2)+C\sin(x^2) + C
∫x2(x3+1)5 dx\int x^2(x^3 + 1)^5\,dx x3+1x^3 + 1 3x2 dx3x^2\,dx (x3+1)618+C\frac{(x^3 + 1)^6}{18} + C
∫tan⁡x dx=∫sin⁡xcos⁡x dx\int \tan x\,dx = \int \frac{\sin x}{\cos x}\,dx cos⁡x\cos x −sin⁡x dx-\sin x\,dx −ln⁡∣cos⁡x∣+C=ln⁡∣sec⁡x∣+C-\ln\lvert \cos x \rvert + C = \ln\lvert \sec x \rvert + C
∫ex1+e2x dx\int \frac{e^x}{1 + e^{2x}}\,dx exe^x ex dxe^x\,dx tan⁡−1(ex)+C\tan^{-1}(e^x) + C
∫xx−3 dx\int x\sqrt{x - 3}\,dx x−3x - 3 (so x=u+3x = u + 3) dxdx 25(x−3)5/2+2(x−3)3/2+C\frac{2}{5}(x - 3)^{5/2} + 2(x - 3)^{3/2} + C

The last row shows a second trick: when a leftover xx remains, solve u=g(x)u = g(x) for xx and rewrite everything in uu.

python · try it yourself
import sympy as sp

x = sp.symbols('x', positive=True)
for f in [x**2 * (x**3 + 1)**5, sp.exp(x) / (1 + sp.exp(2*x)), x * sp.sqrt(x - 3)]:
    F = sp.integrate(f, x, manual=True)     # manual=True: use hand-style rules like substitution
    print(f"∫ {f} dx = {sp.factor(F)}")
    print("   check F' - f =", sp.simplify(sp.diff(F, x) - f))
∫ x**2*(x**3 + 1)**5 dx = x**3*(x**3 + 2)*(x**6 + x**3 + 1)*(x**6 + 3*x**3 + 3)/18
   check F' - f = 0
∫ exp(x)/(exp(2*x) + 1) dx = atan(exp(x))
   check F' - f = 0
∫ x*sqrt(x - 3) dx = 2*(x - 3)**(3/2)*(x + 2)/5
   check F' - f = 0

The first answer differs from the table's (x3+1)618\frac{(x^3 + 1)^6}{18} by the constant 118\frac{1}{18} (expand both to see it), because SymPy expanded before integrating; the third is the table's answer factored, (x−3)3/2⋅2x+45(x - 3)^{3/2} \cdot \frac{2x + 4}{5}. Different-looking antiderivatives are fine; the check F′−f=0F' - f = 0 is what counts.

Definite integrals: change the limits

Substitution Rule for definite integrals. If g′g' is continuous on [a,b][a, b] and ff is continuous on the range of u=g(x)u = g(x), then

∫abf(g(x))⋅g′(x) dx=∫g(a)g(b)f(u) du\int_a^b f(g(x)) \cdot g'(x)\,dx = \int_{g(a)}^{g(b)} f(u)\,du.

Proof. With F′=fF' = f, both sides equal F(g(b))−F(g(a))F(g(b)) - F(g(a)) by FTC Part 2 (left side: F∘gF \circ g is an antiderivative of the integrand). ∎

Changing the limits means you never need to go back to xx:

∫02x1+x2 dx,u=1+x2, du=2x dx,x=0→u=1,x=2→u=5=12∫15u du=12⋅23[u3/2]15=55−13≈3.3934\begin{aligned} &\int_0^2 x\sqrt{1 + x^2}\,dx, \qquad u = 1 + x^2,\ du = 2x\,dx, \qquad x = 0 \to u = 1, \qquad x = 2 \to u = 5 \\ &= \frac{1}{2} \int_1^5 \sqrt{u}\,du = \frac{1}{2} \cdot \frac{2}{3}\Big[u^{3/2}\Big]_1^5 = \frac{5\sqrt{5} - 1}{3} \approx 3.3934 \end{aligned}

SymPy's Integral.transform performs exactly this change of variable, limits included:

python · try it yourself
import sympy as sp

x, u = sp.symbols('x u', positive=True)
I = sp.Integral(x * sp.sqrt(1 + x**2), (x, 0, 2))
J = I.transform(1 + x**2, u)            # substitute u = 1 + x²
print("after substitution:", J)
print("value:", J.doit(), "≈", round(float(J.doit()), 4), "   direct:", I.doit())
after substitution: Integral(sqrt(u)/2, (u, 1, 5))
value: -1/3 + 5*sqrt(5)/3 ≈ 3.3934    direct: -1/3 + 5*sqrt(5)/3

Symmetry

Theorem. Let ff be continuous on [−a,a][-a, a].

  • If ff is even (f(−x)=f(x)f(-x) = f(x)), then ∫−aaf(x) dx=2∫0af(x) dx\int_{-a}^{a} f(x)\,dx = 2\int_0^a f(x)\,dx.
  • If ff is odd (f(−x)=−f(x)f(-x) = -f(x)), then ∫−aaf(x) dx=0\int_{-a}^{a} f(x)\,dx = 0.

Proof. Split at 0 and substitute u=−xu = -x in the left half (du=−dxdu = -dx):

∫−a0f(x) dx=−∫a0f(−u) du=∫0af(−u) du\int_{-a}^{0} f(x)\,dx = -\int_a^0 f(-u)\,du = \int_0^a f(-u)\,du

For even ff this is ∫0af(u) du\int_0^a f(u)\,du, so the total is twice that. For odd ff it is −∫0af(u) du-\int_0^a f(u)\,du, which cancels the right half. ∎

So ∫−33x5⋅cos⁡(x)⋅ex2/10 dx=0\int_{-3}^{3} x^5 \cdot \cos(x) \cdot e^{x^2/10}\,dx = 0 without any computation: the integrand is odd⋅even⋅even=odd\text{odd} \cdot \text{even} \cdot \text{even} = \text{odd}. See also Symmetry.

python · try it yourself
import numpy as np
from scipy.integrate import quad

odd = lambda x: x**5 * np.cos(x) * np.exp(x**2 / 10)
even = lambda x: x**4 * np.cos(x)
print("odd  over [-3, 3]:", round(quad(odd, -3, 3)[0], 10))
print("even over [-3, 3]:", round(quad(even, -3, 3)[0], 6), "  2 × over [0, 3]:", round(2 * quad(even, 0, 3)[0], 6))
odd  over [-3, 3]: 0.0
even over [-3, 3]: -72.12618   2 × over [0, 3]: -72.12618

In software

  • Change of variables for probability densities. If Y=g(X)Y = g(X) with gg increasing, the density of YY is fX(g−1(y))⋅(g−1)′(y)f_X(g^{-1}(y)) \cdot (g^{-1})'(y), the substitution rule in disguise. It is the basis of normalising flows in generative ML and of inverse-transform sampling: feeding uniform random numbers through an inverse CDF.
  • Reparametrising time. Animations remap tt through an easing function s=e(t)s = e(t). Integrating a quantity over the eased parameter uses ds=e′(t) dtds = e'(t)\,dt.
  • Numerical quadrature tricks. Substitutions such as x=tan⁡(θ)x = \tan(\theta) or x=t2x = t^2 remove singularities or map infinite intervals to finite ones before a quadrature routine runs; SciPy's quad does this internally for infinite limits.

Exercises

Exercise 1: Indefinite

Compute ∫sin⁡x⋅cos⁡4x dx\int \sin x \cdot \cos^4 x\,dx.

Answer

−cos⁡5x5+C-\frac{\cos^5 x}{5} + C.

Solution

u=cos⁡xu = \cos x, du=−sin⁡x dxdu = -\sin x\,dx: ∫−u4 du=−u55+C\int -u^4\,du = -\frac{u^5}{5} + C.

Exercise 2: Definite with new limits

Compute ∫1e(ln⁡x)2x dx\int_1^e \frac{(\ln x)^2}{x}\,dx.

Answer

13\frac{1}{3}.

Solution
u=ln⁡x, du=dxx;x=1→u=0,x=e→u=1∫01u2 du=13\begin{aligned} &u = \ln x,\ du = \frac{dx}{x}; \qquad x = 1 \to u = 0, \qquad x = e \to u = 1 \\ &\int_0^1 u^2\,du = \frac{1}{3} \end{aligned}
python · try it yourself
import sympy as sp
x = sp.symbols('x', positive=True)
print(sp.integrate(sp.log(x)**2 / x, (x, 1, sp.E)))
1/3

Exercise 3: Back-substitution for x

Compute ∫x(x+1)3 dx\int \frac{x}{(x + 1)^3}\,dx.

Answer

−1x+1+12(x+1)2+C-\frac{1}{x + 1} + \frac{1}{2(x + 1)^2} + C.

Solution
u=x+1, x=u−1, dx=du∫u−1u3 du=∫(u−2−u−3) du=−u−1+u−22+C\begin{aligned} &u = x + 1,\ x = u - 1,\ dx = du \\ &\int \frac{u - 1}{u^3}\,du = \int (u^{-2} - u^{-3})\,du = -u^{-1} + \frac{u^{-2}}{2} + C \end{aligned}

Exercise 4: Symmetry

Evaluate ∫−22(x3+3x2−sin⁡x) dx\int_{-2}^{2} (x^3 + 3x^2 - \sin x)\,dx.

Answer
Solution

x3x^3 and sin⁡x\sin x are odd, so they contribute 0. 3x23x^2 is even: 2∫023x2 dx=2⋅8=162\int_0^2 3x^2\,dx = 2 \cdot 8 = 16.

Test yourself

Which substitution handles ∫x⋅ex2 dx\int x \cdot e^{x^2}\,dx?

  1. u=xu = x
  2. u=x2u = x^2
  3. u=exu = e^x
  4. u=xex2u = x e^{x^2}

In ∫0π/2cos⁡x⋅sin⁡3x dx\int_0^{\pi/2} \cos x \cdot \sin^3 x\,dx with u=sin⁡xu = \sin x, what are the new limits?

  1. 0 and 1
  2. 0 and π/2\pi/2
  3. 1 and 0
  4. −1 and 1

ff is odd and continuous. What is ∫−55f(x) dx\int_{-5}^{5} f(x)\,dx?

  1. 2∫05f2\int_0^5 f
  2. f(5)−f(−5)f(5) - f(-5)
  3. 0
  4. It depends on ff