u-Substitution
u-substitution is the reverse of the chain rule: it undoes a composition of functions inside an integral. It is the workhorse for integrating the kernels of many probability densities, especially the bell-curve kernel used to model biological measurements like birth weights or blood pressure. The same trick handles rate integrals with an exponential inside, such as a drug’s exponential elimination.
The idea
The chain rule says . Reading that backwards gives the substitution rule: if an integrand looks like multiplied by its inner derivative , then
For a definite integral, change the limits too:
Steps
- Choose , an inner function whose derivative also appears (up to a constant).
- Compute and solve for or .
- Rewrite the whole integral in terms of .
- Integrate in , then substitute back (indefinite) or change the limits (definite).
Worked example
Compute .
Let , so — and is exactly what sits in front of the exponential. The integral becomes
A closely related normal-density kernel: . Take , , so :
As a definite check,
Computing it
R
# Numeric check: integral of x*exp(-x^2) from 0 to Inf should be 0.5
integrate(function(x) x * exp(-x^2), 0, Inf)$value # 0.5
$```
### Python
```python
import sympy as sp
from scipy.integrate import quad
import numpy as np
x = sp.symbols("x")
print(sp.integrate(2*x*sp.exp(x**2), x)) # exp(x**2)
print(sp.integrate(x*sp.exp(-x**2), (x, 0, sp.oo))) # 1/2
val, _ = quad(lambda t: t*np.exp(-t**2), 0, np.inf)
print(val) # 0.4999999999999999
exp(x**2)
1/2
0.5000000000000001
Julia
using Symbolics, QuadGK
@variables x
# Numeric verification of the substitution result
println(quadgk(t -> t*exp(-t^2), 0, Inf)[1]) # 0.5
# Symbolic antiderivative check: d/dx(-1/2 e^{-x^2}) = x e^{-x^2}
D = Differential(x)
expand_derivatives(D(-0.5*exp(-x^2))) # x*exp(-x^2)
Why it matters for statistics
Normalizing a density and computing moments constantly produces integrands of the form . For the normal density the substitution reduces any Gaussian integral to the standard ; for the exponential and gamma families, handles the exponential factor.