The Comparison Tests
Most positive series are not geometric or -series, but they behave like one for large . 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- in algorithm analysis.
The survey table is in Convergence Tests; the yardsticks used here come from Series (geometric) and The Integral Test (-series).
The Direct Comparison Test
Theorem. Suppose for all (or for all some ).
- If converges, then converges.
- If diverges, then diverges.
Proof. Let and . Both sequences are non-decreasing because the terms are non-negative. In case 1, , so : 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.
The Limit Comparison Test
Direct comparison breaks on series like , where the natural inequality points the useless way. The fix is to compare growth rates instead of individual terms.
Theorem. Suppose , and
Then and either both converge or both diverge.
Proof. Take in the definition of the limit: there is with for , i.e.
If converges, so does , and the right inequality with direct comparison gives convergence of . If diverges, so does , and the left inequality forces to diverge. ∎
Edge cases are one-sided: if and converges, then converges; if and diverges, then diverges.
Choosing . Keep only the dominant powers in numerator and denominator:
| Series | Compare with | Limit | Verdict |
|---|---|---|---|
| 1 | converges | ||
| (or ) | 1 (or 3) | converges | |
| 1 | diverges () | ||
| 1 | diverges | ||
| converges |
The last two rows use Taylor intuition: and for small (see Taylor and Maclaurin Series).
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: is eventually smaller than , which converges, so converges. Logarithms grow slower than any positive power, which is why they rarely change a verdict.
Estimating sums by comparison
If , the tails satisfy , and the right side is often a geometric or integral bound you can compute. For :
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- is limit comparison. If with , then . When you simplify to you are doing exactly what the proof above does: sandwiching between and for large . See time complexity.
- Linear-time heap construction. Bottom-up heapify does at most swaps for each of about nodes at height , so the work is at most . Comparing with the geometric (their ratio ) proves the sum converges; its value is 1, so heapify is , not .
- Convergence of numerical loops. An iteration whose step sizes are bounded by with 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) , b) , c) .
Answer
a) converges, b) diverges, c) converges.
Solution
Exercise 2: Limit comparison
Decide convergence of and of .
Answer
The first converges, the second diverges.
Solution
Exercise 3: A tail bound
Using and the integral bound for -series, how many terms of guarantee a tail below 0.001? Check numerically.
Answer
terms (tail ); the actual tail is about .
Solution
Strictly is needed for "", but at the true tail is already below the bound because the comparison is not tight.
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 exactly with SymPy, and count the swaps bottom-up heapify needs in the worst case for a full binary heap with nodes.
Answer
The sum is 1; the worst-case swap count is , just under .
Solution
A full heap of height has nodes at height , each needing at most swaps.
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
for all . What follows?
- diverges
- converges
- Nothing: being below a divergent series proves nothing
- is eventually 0
Which series is the right comparison for ?
and diverges. What do you know about ?
- It converges
- It diverges
- Nothing
- Its sum is 0