TExcelTAD
Home › Calculus in Depth › The Comparison Tests

The Comparison Tests

Most positive series are not geometric or pp-series, but they behave like one for large nn. The comparison tests turn that intuition into proofs: bound the terms by a series you already understand, or show the ratio of terms tends to a positive constant. The limit version is, in disguise, the same idea as big-Θ\Theta in algorithm analysis.

The survey table is in Convergence Tests; the yardsticks used here come from Series (geometric) and The Integral Test (pp-series).

The Direct Comparison Test

Theorem. Suppose 0≤an≤bn0 \le a_n \le b_n for all nn (or for all n≥n \ge some NN).

  1. If ∑bn\sum b_n converges, then ∑an\sum a_n converges.
  2. If ∑an\sum a_n diverges, then ∑bn\sum b_n diverges.

Proof. Let sn=∑i=1nais_n = \sum_{i=1}^{n} a_i and tn=∑i=1nbit_n = \sum_{i=1}^{n} b_i. Both sequences are non-decreasing because the terms are non-negative. In case 1, tn≤T=∑bnt_n \le T = \sum b_n, so sn≤tn≤Ts_n \le t_n \le T: {sn}\{s_n\} is non-decreasing and bounded above, hence convergent by the Monotone Convergence Theorem (Sequences). Case 2 is the contrapositive of case 1 with the roles swapped. ∎

Two warnings. The inequality must go the right way: being smaller than a divergent series, or larger than a convergent one, tells you nothing. And the terms must be non-negative; for series with mixed signs use absolute values (Absolute Convergence and the Ratio and Root Tests).

Examples.

∑13n+n:0<13n+n<13n, geometric with r=13⇒converges∑ln⁡nn:ln⁡nn>1n for n≥3, harmonic diverges⇒diverges∑sin⁡2(n)n2:0≤sin⁡2(n)n2≤1n2, p=2⇒converges\begin{aligned} &\sum \frac{1}{3^n + n}{:} && 0 < \frac{1}{3^n + n} < \frac{1}{3^n}, \text{ geometric with } r = \tfrac{1}{3} && \Rightarrow \text{converges} \\ &\sum \frac{\ln n}{n}{:} && \frac{\ln n}{n} > \frac{1}{n} \text{ for } n \ge 3, \text{ harmonic diverges} && \Rightarrow \text{diverges} \\ &\sum \frac{\sin^2(n)}{n^2}{:} && 0 \le \frac{\sin^2(n)}{n^2} \le \frac{1}{n^2},\ p = 2 && \Rightarrow \text{converges} \end{aligned}

The Limit Comparison Test

Direct comparison breaks on series like ∑12n−1\sum \frac{1}{2^n - 1}, where the natural inequality 12n−1>12n\frac{1}{2^n - 1} > \frac{1}{2^n} points the useless way. The fix is to compare growth rates instead of individual terms.

Theorem. Suppose an>0a_n > 0, bn>0b_n > 0 and

lim⁡n→∞anbn=cwith 0<c<∞.\lim_{n \to \infty} \frac{a_n}{b_n} = c \quad \text{with } 0 < c < \infty.

Then ∑an\sum a_n and ∑bn\sum b_n either both converge or both diverge.

Proof. Take ε=c/2\varepsilon = c/2 in the definition of the limit: there is NN with c/2<an/bn<3c/2c/2 < a_n/b_n < 3c/2 for n>Nn > N, i.e.

c2 bn<an<3c2 bnfor n>N\frac{c}{2}\, b_n < a_n < \frac{3c}{2}\, b_n \qquad \text{for } n > N

If ∑bn\sum b_n converges, so does ∑3c2bn\sum \frac{3c}{2} b_n, and the right inequality with direct comparison gives convergence of ∑an\sum a_n. If ∑bn\sum b_n diverges, so does ∑c2bn\sum \frac{c}{2} b_n, and the left inequality forces ∑an\sum a_n to diverge. ∎

Edge cases are one-sided: if an/bn→0a_n/b_n \to 0 and ∑bn\sum b_n converges, then ∑an\sum a_n converges; if an/bn→∞a_n/b_n \to \infty and ∑bn\sum b_n diverges, then ∑an\sum a_n diverges.

Choosing bnb_n. Keep only the dominant powers in numerator and denominator:

Series Compare with Limit cc Verdict
∑12n−1\sum \frac{1}{2^n - 1} 1/2n1/2^n 1 converges
∑3n2+5n4−n+1\sum \frac{3n^2 + 5}{n^4 - n + 1} 3/n23/n^2 (or 1/n21/n^2) 1 (or 3) converges
∑n+2n+7\sum \frac{\sqrt{n + 2}}{n + 7} 1/n1/\sqrt{n} 1 diverges (p=12p = \frac{1}{2})
∑sin⁡(1/n)\sum \sin(1/n) 1/n1/n 1 diverges
∑(1−cos⁡(1/n))\sum (1 - \cos(1/n)) 1/n21/n^2 12\frac{1}{2} converges

The last two rows use Taylor intuition: sin⁡x≈x\sin x \approx x and 1−cos⁡x≈x2/21 - \cos x \approx x^2/2 for small xx (see Taylor and Maclaurin Series).

python · try it yourself
import sympy as sp

n = sp.symbols("n", positive=True)
pairs = [
    ((3*n**2 + 5) / (n**4 - n + 1), 1 / n**2),
    (sp.sqrt(n + 2) / (n + 7), 1 / sp.sqrt(n)),
    (sp.sin(1 / n), 1 / n),
    (1 - sp.cos(1 / n), 1 / n**2),
    (sp.log(n) / n**2, 1 / n**sp.Rational(3, 2)),
]
for a, b in pairs:
    print(f"a = {str(a):28s} b = {str(b):10s} lim a/b = {sp.limit(a / b, n, sp.oo)}")
a = (3*n**2 + 5)/(n**4 - n + 1)  b = n**(-2)    lim a/b = 3
a = sqrt(n + 2)/(n + 7)          b = 1/sqrt(n)  lim a/b = 1
a = sin(1/n)                     b = 1/n        lim a/b = 1
a = 1 - cos(1/n)                 b = n**(-2)    lim a/b = 1/2
a = log(n)/n**2                  b = n**(-3/2)  lim a/b = 0

The last line is the "limit 0" edge case: (ln⁡n)/n2(\ln n)/n^2 is eventually smaller than 1/n3/21/n^{3/2}, which converges, so ∑(ln⁡n)/n2\sum (\ln n)/n^2 converges. Logarithms grow slower than any positive power, which is why they rarely change a verdict.

Estimating sums by comparison

If 0≤an≤bn0 \le a_n \le b_n, the tails satisfy Rn=∑k>nak≤∑k>nbkR_n = \sum_{k>n} a_k \le \sum_{k>n} b_k, and the right side is often a geometric or integral bound you can compute. For ∑13n+n\sum \frac{1}{3^n + n}:

Rn≤∑k=n+1∞13k=1/3n+11−1/3=12⋅3nR_n \le \sum_{k=n+1}^{\infty} \frac{1}{3^k} = \frac{1/3^{n+1}}{1 - 1/3} = \frac{1}{2 \cdot 3^n}
python · try it yourself
from fractions import Fraction

def s(n):
    return sum(Fraction(1, 3**k + k) for k in range(1, n + 1))

S = float(s(60))                      # 60 terms: tail < 1e-28, effectively exact
for n in (3, 6, 12):
    tail = S - float(s(n))
    bound = 1 / (2 * 3**n)
    print(f"n={n:2d}  s_n={float(s(n)):.10f}  true tail {tail:.3e}  bound {bound:.3e}")
print(f"S ≈ {S:.12f}")
n= 3  s_n=0.3742424242  true tail 1.784e-02  bound 1.852e-02
n= 6  s_n=0.3913999324  true tail 6.842e-04  bound 6.859e-04
n=12  s_n=0.3920831917  true tail 9.408e-07  bound 9.408e-07
S ≈ 0.392084132502

In software

  • Big-Θ\Theta is limit comparison. If f(n)/g(n)→cf(n)/g(n) \to c with 0<c<∞0 < c < \infty, then f=Θ(g)f = \Theta(g). When you simplify 3n2+5nlog⁡n+73n^2 + 5n \log n + 7 to Θ(n2)\Theta(n^2) you are doing exactly what the proof above does: sandwiching ff between c2g\frac{c}{2}g and 3c2g\frac{3c}{2}g for large nn. See time complexity.
  • Linear-time heap construction. Bottom-up heapify does at most hh swaps for each of about n/2h+1n/2^{h+1} nodes at height hh, so the work is at most n∑h/2h+1n \sum h/2^{h+1}. Comparing h/2h+1h/2^{h+1} with the geometric (2/3)h(2/3)^h (their ratio →0\to 0) proves the sum converges; its value is 1, so heapify is O(n)O(n), not O(nlog⁡n)O(n \log n).
  • Convergence of numerical loops. An iteration whose step sizes are bounded by CrkC r^k with r<1r < 1 has a total movement bounded by a geometric series, which proves it converges (the core of the contraction-mapping argument behind value iteration in RL).

Exercises

Exercise 1: Direct comparison

Decide convergence: a) ∑1n3+2n\sum \frac{1}{n^3 + 2n}, b) ∑2+cos⁡nn\sum \frac{2 + \cos n}{n}, c) ∑5n6n+1\sum \frac{5^n}{6^n + 1}.

Answer

a) converges, b) diverges, c) converges.

Solution
a) 0<1n3+2n<1n3, p=3>1b) 2+cos⁡nn≥1n>0, harmonic divergesc) 0<5n6n+1<(56)n, geometric with r=56\begin{aligned} &\text{a) } 0 < \frac{1}{n^3 + 2n} < \frac{1}{n^3},\ p = 3 > 1 \\ &\text{b) } \frac{2 + \cos n}{n} \ge \frac{1}{n} > 0, \text{ harmonic diverges} \\ &\text{c) } 0 < \frac{5^n}{6^n + 1} < \left(\tfrac{5}{6}\right)^n, \text{ geometric with } r = \tfrac{5}{6} \end{aligned}

Exercise 2: Limit comparison

Decide convergence of ∑n+42n3−n+6\sum \frac{n + 4}{2n^3 - n + 6} and of ∑1n2+3n\sum \frac{1}{\sqrt{n^2 + 3n}}.

Answer

The first converges, the second diverges.

Solution
n+42n3−n+6÷1n2=n3+4n22n3−n+6→12, and ∑1n2 converges1n2+3n÷1n=nn2+3n=11+3/n→1, and ∑1n diverges\begin{aligned} &\frac{n + 4}{2n^3 - n + 6} \div \frac{1}{n^2} = \frac{n^3 + 4n^2}{2n^3 - n + 6} \to \frac{1}{2}, \text{ and } \sum \frac{1}{n^2} \text{ converges} \\ &\frac{1}{\sqrt{n^2 + 3n}} \div \frac{1}{n} = \frac{n}{\sqrt{n^2 + 3n}} = \frac{1}{\sqrt{1 + 3/n}} \to 1, \text{ and } \sum \frac{1}{n} \text{ diverges} \end{aligned}

Exercise 3: A tail bound

Using 1n2+n+1<1n2\frac{1}{n^2 + n + 1} < \frac{1}{n^2} and the integral bound for pp-series, how many terms of ∑1n2+n+1\sum \frac{1}{n^2 + n + 1} guarantee a tail below 0.001? Check numerically.

Answer

n=1000n = 1000 terms (tail ≤1/n\le 1/n); the actual tail is about 9.990×10−49.990 \times 10^{-4}.

Solution
Rn≤∑k>n1k2≤∫n∞dxx2=1n<0.001  ⇐  n>1000R_n \le \sum_{k>n} \frac{1}{k^2} \le \int_n^\infty \frac{dx}{x^2} = \frac{1}{n} < 0.001 \;\Leftarrow\; n > 1000

Strictly n>1000n > 1000 is needed for "<<", but at n=1000n = 1000 the true tail is already below the bound because the comparison is not tight.

python · try it yourself
def partial(n):
    s = 0.0
    for k in range(n, 0, -1):
        s += 1 / (k * k + k + 1)
    return s

big = partial(200_000) + 1 / 200_000      # + tail estimate for the rest
print(f"tail after 1000 terms ≈ {big - partial(1000):.4e}")
tail after 1000 terms ≈ 9.9900e-04

Exercise 4: Heapify bound

Compute ∑h=0∞h2h+1\sum_{h=0}^{\infty} \frac{h}{2^{h+1}} exactly with SymPy, and count the swaps bottom-up heapify needs in the worst case for a full binary heap with n=220−1n = 2^{20} - 1 nodes.

Answer

The sum is 1; the worst-case swap count is 220−21=10485552^{20} - 21 = 1048555, just under nn.

Solution

A full heap of height H=19H = 19 has 2H−h2^{H-h} nodes at height hh, each needing at most hh swaps.

python · try it yourself
import sympy as sp

h = sp.symbols("h", integer=True, nonnegative=True)
print("∑ h/2^(h+1) =", sp.summation(h / 2**(h + 1), (h, 0, sp.oo)))
H = 19
n = 2**(H + 1) - 1
swaps = sum((2**(H - k)) * k for k in range(H + 1))
print("n =", n, " worst-case swaps =", swaps, " swaps/n =", round(swaps / n, 6))
∑ h/2^(h+1) = 1
n = 1048575  worst-case swaps = 1048555  swaps/n = 0.999981

Test yourself

0≤an≤1/n0 \le a_n \le 1/n for all nn. What follows?

  1. ∑an\sum a_n diverges
  2. ∑an\sum a_n converges
  3. Nothing: being below a divergent series proves nothing
  4. ana_n is eventually 0

Which series is the right comparison for ∑2n+1n3+4\sum \frac{2n + 1}{n^3 + 4}?

  1. ∑1/n2\sum 1/n^2
  2. ∑1/n\sum 1/n
  3. ∑1/n3\sum 1/n^3
  4. ∑2n\sum 2^n

lim⁡an/bn=0\lim a_n/b_n = 0 and ∑bn\sum b_n diverges. What do you know about ∑an\sum a_n?

  1. It converges
  2. It diverges
  3. Nothing
  4. Its sum is 0