Integration by Parts
Substitution reverses the chain rule; integration by parts reverses the product rule. It trades the integral of a product for another integral that is, with a good choice, simpler. This lesson derives the formula, gives a strategy for choosing the parts, and covers the three advanced patterns: repeated parts, integrals that reappear and must be solved for, and reduction formulas. For a first look see Integration by Parts.
The formula
The product rule says . Integrate both sides and rearrange:
With and , so and :
For definite integrals, by FTC Part 2:
Choosing u and dv
You must be able to integrate , and should be simpler than . A common heuristic (often called LIATE) picks as the first type present in this list:
| Priority for | Type | Examples |
|---|---|---|
| 1 | Logarithmic | |
| 2 | Inverse trig | , |
| 3 | Algebraic | , |
| 4 | Trigonometric | |
| 5 | Exponential |
The functions at the top get simpler when differentiated (); those at the bottom stay the same size when integrated. It is a guide, not a law.
Examples.
The last one also needs a substitution, , for the remaining integral. Combining techniques is normal.
Repeated parts and the tabular shortcut
needs parts three times, each time lowering the power. Organised as a table, differentiate down to 0 and integrate the same number of times, then multiply along diagonals with alternating signs:
sign u (differentiate) dv (integrate)
+ x³ eˣ
− 3x² eˣ
+ 6x eˣ
− 6 eˣ
0 eˣimport sympy as sp
x = sp.symbols('x')
def tabular(u, dv):
"""Integration by parts repeated until u differentiates to 0."""
total, sign, v = 0, 1, dv
while u != 0:
v = sp.integrate(v, x)
total += sign * u * v
u, sign = sp.diff(u, x), -sign
return total
for u, dv in [(x**3, sp.exp(x)), (x**2, sp.cos(2 * x))]:
F = sp.factor(tabular(u, dv))
print(f"∫ {u}·{dv} dx = {F}")
print(" check:", sp.simplify(sp.diff(F, x) - u * dv) == 0)∫ x**3·exp(x) dx = (x**3 - 3*x**2 + 6*x - 6)*exp(x)
check: True
∫ x**2·cos(2*x) dx = (2*x**2*sin(2*x) + 2*x*cos(2*x) - sin(2*x))/4
check: True
When the integral comes back
For , parts twice returns the original integral:
Treat as an unknown and solve the equation; do not keep integrating in circles. (The two choices of must be the same type, both trig here; switching to the second time undoes the first step.)
Reduction formulas
Parts can lower an exponent in general. For with , , the boundary term vanishes and using gives
so . Products of such ratios lead to Wallis's product for :
import math
from fractions import Fraction
from scipy.integrate import quad
def I(n): # the reduction formula, applied recursively
if n == 0: return math.pi / 2
if n == 1: return 1.0
return (n - 1) / n * I(n - 2)
for n in (2, 5, 6, 11):
numeric = quad(lambda t: math.sin(t)**n, 0, math.pi / 2)[0]
print(f"I_{n:<2} reduction = {I(n):.10f} quad = {numeric:.10f}")
# Wallis: π/2 = Π (2k/(2k−1))·(2k/(2k+1))
p = Fraction(1)
for k in range(1, 2001):
p *= Fraction(4 * k * k, 4 * k * k - 1)
print("Wallis product, 2000 factors: 2·P =", round(2 * float(p), 6), " π =", round(math.pi, 6))I_2 reduction = 0.7853981634 quad = 0.7853981634
I_5 reduction = 0.5333333333 quad = 0.5333333333
I_6 reduction = 0.4908738521 quad = 0.4908738521
I_11 reduction = 0.3694083694 quad = 0.3694083694
Wallis product, 2000 factors: 2·P = 3.1412 π = 3.141593
The reduction formula matches numerical quadrature exactly. Wallis's product is beautiful but slow: 2000 factors give only four correct digits, because its error falls like .
In software
- Weak forms and the finite element method. FEM solvers (structural analysis, heat flow, cloth simulation) multiply a PDE by a test function and integrate by parts to move a derivative off the unknown; that is what makes piecewise-linear elements usable.
- Score matching and Stein's identity. In generative ML, integration by parts turns an objective involving an unknown density into one involving only the model's score , which is how diffusion models are trained without computing normalising constants.
- Summation by parts. The discrete version (Abel summation) appears in the analysis of algorithms and in convergence proofs for series.
Exercises
Exercise 1: Basic
Compute .
Answer
.
Solution
, , : .
Exercise 2: A definite integral with a log
Compute .
Answer
.
Solution
import sympy as sp
x = sp.symbols('x', positive=True)
r = sp.integrate(x**2 * sp.log(x), (x, 1, sp.E))
print(sp.simplify(r), round(float(r), 4))1/9 + 2*exp(3)/9 4.5746
Exercise 3: Solve for the integral
Compute .
Answer
.
Solution
Exercise 4: A reduction formula
Show that , and use it for .
Answer
.
Solution
, : , , and . For : .
Test yourself
Integration by parts comes from which differentiation rule?
- The chain rule
- The quotient rule
- The product rule
- The power rule
For , the better choice is…
- ,
- ,
- ,
- Parts does not apply
Using with , what is ?