32. The integral test and p-series

📖 Reading · 10 min
💡 Every code box below is live — edit it and hit Run.

Oresme's grouping argument settled the harmonic series, but it was a one-off trick, tailored to that specific series. This lesson builds a general-purpose replacement: compare a series directly to an integral, using the fact that a decreasing function's values bound a sum of rectangles from above and below — the Riemann-sum picture from §4.1, run in reverse.

The integral test

Let f be continuous, positive, and decreasing on [1,\infty), and let a_n=f(n). Then \sum_{n=1}^\infty a_n\ \text{converges}\iff\int_1^\infty f(x)\,dx\ \text{converges}

Why this works. Because f is decreasing, the rectangle of height f(n) and width 1 sitting over [n,n+1] lies entirely below the curve there, while the rectangle over [n-1,n] lies entirely above it. Stacking these comparisons across all n sandwiches the series between two shifted copies of the same improper integral (§4.10) — so the series and the integral are forced to converge or diverge together. This is the Riemann-sum idea in reverse: instead of an integral being approximated by a sum, a sum is being bounded by an integral.

Both conditions — positive and decreasing — are load-bearing. Decreasing is what makes the rectangle comparison valid at all; without it, the series could zigzag in ways no monotone integral bound could capture.

p-series

A p-series is \displaystyle\sum_{n=1}^\infty\frac1{n^p} for a constant p>0. Apply the integral test with f(x)=\frac1{x^p}, positive and decreasing for p>0:

\int_1^\infty x^{-p}\,dx=\begin{cases}\dfrac{1}{p-1}&p>1\\[4pt]\text{diverges}&p\le1\end{cases}

(This is exactly §4.10's improper-integral p-test, computed there for the general power function — the calculus doesn't change, only which family of series it's now settling.) So:

\sum_{n=1}^\infty\frac1{n^p}\ \text{converges}\iff p>1

The harmonic series is the p=1 boundary case — exactly the threshold where convergence fails, which is why Oresme's series needed a dedicated argument rather than following from an easier, already-known pattern: there was no easier pattern yet. \sum\frac1{n^2} (p=2) converges (to \frac{\pi^2}6, first seen numerically in §7.2); \sum\frac1{\sqrt n} (p=\frac12) diverges.

Beyond p-series: where the integral test earns its keep

The real value of the integral test is series that aren't p-series at all — anything where the antiderivative is computable but no earlier pattern applies. A classic pair:

\sum_{n=2}^\infty\frac1{n\ln n}\qquad\text{versus}\qquad\sum_{n=2}^\infty\frac1{n(\ln n)^2}

Both have terms shrinking to 0; neither is a p-series (the extra \ln n factor breaks that pattern); both yield to substitution (§4.5, u=\ln x) once cast as integrals — and, remarkably, they land on opposite sides of convergence, despite looking almost identical.

Doing it in Python

The p-series pattern, confirmed for several values of p straddling the p=1 threshold:

import sympy as sp

x = sp.Symbol('x', positive=True)

for p in (sp.Rational(1, 2), 1, 2, 3):
    result = sp.integrate(x**(-p), (x, 1, sp.oo))
    verdict = "diverges" if result == sp.oo else f"converges to {result}"
    print(f"p = {p!s:>4}: integral = {verdict}")

The two near-identical series that diverge and converge on opposite sides of the \ln factor, resolved with the integral test and u=\ln x:

import sympy as sp

x = sp.Symbol('x', positive=True)

I1 = sp.integrate(1 / (x * sp.ln(x)), (x, 2, sp.oo))
I2 = sp.integrate(1 / (x * sp.ln(x)**2), (x, 2, sp.oo))
print(f"integral of 1/(x ln x)     = {I1}")
print(f"integral of 1/(x (ln x)^2) = {I2}")
print("\nsame-looking series, opposite convergence behavior")

Confirming the rectangle-sandwich picture numerically — the harmonic series' partial sum compared to \ln N, showing the integral really does bound the sum on both sides:

import math

for N in (10, 100, 1000):
    S_N = sum(1/n for n in range(1, N + 1))
    lower = math.log(N + 1)          # integral from 1 to N+1
    upper = 1 + math.log(N)          # 1 + integral from 1 to N
    print(f"N={N:>5}: ln(N+1)={lower:.4f} <= S_N={S_N:.4f} <= 1+ln(N)={upper:.4f}")

Worked example

Determine whether \displaystyle\sum_{n=2}^\infty\frac1{n(\ln n)^2} converges, using the integral test.

f(x)=\frac1{x(\ln x)^2} is positive and decreasing for x\ge2 (both x and \ln x grow, so the reciprocal shrinks). Substitute u=\ln x, du=\frac1x dx (§4.5):

\int_2^\infty\frac{dx}{x(\ln x)^2}=\int_{\ln2}^\infty\frac{du}{u^2}=\left[-\frac1u\right]_{\ln2}^\infty=\left(0\right)-\left(-\frac1{\ln2}\right)=\frac1{\ln2}

A finite value.

\boxed{\text{converges, by the integral test}}

Sanity check. \frac1{\ln2}\approx1.44 — a specific finite number, consistent with this being a genuinely convergent improper integral of a \frac1{u^2} shape (a p=2 pattern in the substituted variable u, convergent by the very p-test just derived). Compare to \sum\frac1{n\ln n}, which substitutes to \int\frac{du}u — a p=1 pattern, exactly the harmonic series' divergent boundary case, repeated one layer down. The extra power on \ln n is what tips this series from divergent to convergent — mirroring exactly how the exponent p tips a plain p-series.

Your turn

1. Use the integral test to determine whether \displaystyle\sum_{n=1}^\infty\frac1{n^2+1} converges (it isn't quite a p-series, but \arctan x from §2.7 handles the integral).

2. Without recomputing an integral, use the p-series result to determine whether \displaystyle\sum_{n=1}^\infty n^{-1.001} converges — note how close p is to the harmonic-series boundary.

3. True or false: the integral test can be applied to a_n=\dfrac{\sin n+2}{n^2} directly, since a_n>0 and a_n\to0.

Solutions

1. f(x)=\frac1{x^2+1} is positive and decreasing for x\ge1 (actually for all x\ge0).

\int_1^\infty\frac{dx}{x^2+1}=\Big[\arctan x\Big]_1^\infty=\frac\pi2-\frac\pi4=\frac\pi4

Finite, so \boxed{\text{converges, by the integral test}}.

2. p=1.001>1, so by the p-series test, \boxed{\text{converges}} — even though p sits just barely above the harmonic series' divergent boundary at p=1. (It converges extremely slowly, since it's an infinitesimal nudge past the threshold, but the theorem doesn't care about speed — only about which side of p=1 it lands on.)

3. False. a_n>0 and a_n\to0 are not enough — the integral test additionally requires f to be decreasing, and f(x)=\frac{\sin x+2}{x^2} is not monotonic: the \sin x term makes it wiggle up and down indefinitely as x grows, even while the overall trend is downward. The integral test cannot be applied directly here; a comparison test (§7.7, next) — bounding a_n between two series that can be analyzed — is the right tool for a series like this one.

Check yourself in code

Compute \displaystyle\int_1^\infty x^{-p}\,dx for p=\frac12,1,2,3 using SymPy, printing whether each converges.

Print exactly this:

p =  1/2: diverges
p =    1: diverges
p =    2: converges to 1
p =    3: converges to 1/2
import sympy as sp

x = sp.Symbol('x', positive=True)

for p in (sp.Rational(1, 2), 1, 2, 3):
    result = sp.integrate(x**(-p), (x, 1, sp.oo))
    # print p (right-aligned width 4) and either "diverges" or "converges to <value>"
    print(...)
import sympy as sp

x = sp.Symbol('x', positive=True)

for p in (sp.Rational(1, 2), 1, 2, 3):
    result = sp.integrate(x**(-p), (x, 1, sp.oo))
    verdict = "diverges" if result == sp.oo else f"converges to {result}"
    print(f"p = {p!s:>4}: {verdict}")

The integral test compares a series' terms to a decreasing function's values, sandwiching the partial sums between two copies of the same improper integral — so the series and the integral share a convergence verdict. Its most important corollary is the p-series family, \sum\frac1{n^p}, converging exactly when p>1, with the harmonic series sitting precisely on the divergent boundary at p=1. Beyond p-series, the test settles any series whose terms come from a recognizable, decreasing, integrable function — including near-twin series like \sum\frac1{n\ln n} and \sum\frac1{n(\ln n)^2} that land on opposite sides of convergence despite looking almost identical.

Next: series that don't fit a clean closed-form integral at all, settled instead by direct comparison to a series whose behavior is already known.