Infinite Series: Convergence and Divergence
Can you add up infinitely many numbers and get a finite answer? Sometimes yes: is exactly 1. Sometimes no: grows past every number, even though its terms shrink. This lesson gives the idea of convergence through partial sums, the infinite geometric series, and the first warning signs of divergence, all at an intuitive level.
Partial sums
An infinite series is written . We cannot add infinitely many terms, so we add the first and watch what happens as grows. These are the partial sums:
If the sequence of partial sums approaches a number , the series converges and is its sum. Otherwise it diverges. So an infinite series is really a statement about a sequence: the sequence of running totals.
from itertools import accumulate
halves = [1 / 2**n for n in range(1, 21)]
S = list(accumulate(halves))
for N in [1, 2, 3, 5, 10, 20]:
print(f"S_{N:<2} = {S[N - 1]:.8f} gap to 1 = {1 - S[N - 1]:.8f}")S_1 = 0.50000000 gap to 1 = 0.50000000
S_2 = 0.75000000 gap to 1 = 0.25000000
S_3 = 0.87500000 gap to 1 = 0.12500000
S_5 = 0.96875000 gap to 1 = 0.03125000
S_10 = 0.99902344 gap to 1 = 0.00097656
S_20 = 0.99999905 gap to 1 = 0.00000095
Each new term fills half of the remaining gap, so the gap after terms is exactly , which goes to 0. The sum is 1.
The infinite geometric series
The GP sum formula gives . If , then and
If the terms do not shrink and the series diverges.
| Series | Sum | ||
|---|---|---|---|
| 1 | |||
| 1 | |||
| 5 | |||
| 0.9 | 1 | ||
| 1 | 2 | diverges |
The fourth row explains why exactly: the repeating decimal is this geometric series. Every repeating decimal converts to a fraction this way.
Tip: A bouncing ball that rises to 60% of its previous height each bounce travels a finite total distance, and (with a bit more physics) stops after a finite time. Both totals are geometric series.
Shrinking terms are not enough
If a series converges, its terms must go to 0. Read backwards, that gives the divergence test: if does not go to 0, the series diverges. For example diverges because its terms do not shrink at all (its partial sums jump 1, 0, 1, 0, …).
But terms going to 0 does not guarantee convergence. The harmonic series diverges. Group its terms:
Each bracket is at least , and there are infinitely many brackets, so the sum passes every bound. It does so incredibly slowly:
import math
S, N = 0.0, 0
targets = [2, 5, 10, 15]
for t in targets:
while S < t:
N += 1
S += 1 / N
print(f"harmonic partial sum passes {t:>2} after N = {N:>8} terms (e^{t - 0.5772:.4f} ≈ {math.exp(t - 0.5772):,.0f})")harmonic partial sum passes 2 after N = 4 terms (e^1.4228 ≈ 4)
harmonic partial sum passes 5 after N = 83 terms (e^4.4228 ≈ 83)
harmonic partial sum passes 10 after N = 12367 terms (e^9.4228 ≈ 12,367)
harmonic partial sum passes 15 after N = 1835421 terms (e^14.4228 ≈ 1,835,450)
The partial sums grow like (the constant is the Euler–Mascheroni constant ), so reaching 15 takes almost two million terms. A table of partial sums can easily look like it is settling down when it is not. That is why mathematicians use tests (next lesson) rather than staring at numbers.
In software
- Discounted rewards. In reinforcement learning a reward of 1 per step discounted by is worth in total, a geometric series.
- Harmonic numbers in algorithms. The harmonic sum appears in the analysis of quicksort's average case (about comparisons) and of hashing; the slow divergence is why those costs have a log factor.
- Stopping rules. Numerical code that sums a series stops when the next term is below a tolerance. The harmonic series shows that rule can stop at a wrong "answer" if the series diverges.
For the full definitions, the rigorous proofs and many more examples, see Series and Infinite Series.
Exercises
Exercise 1: A geometric sum
Find
Answer
9
Solution
Exercise 2: Repeating decimal
Write as a fraction.
Answer
Solution
Exercise 3: Converge or diverge?
Decide for each: (a) , (b) , (c) .
Answer
(a) converges, (b) diverges, (c) diverges.
Solution
Exercise 4: Bouncing ball
A ball is dropped from 10 m and each bounce reaches 60% of the previous height. Find the total vertical distance it travels. Check with a loop over 200 bounces.
Answer
40 m
Solution
total, h = 10.0, 10.0
for _ in range(200):
h *= 0.6
total += 2 * h
print(round(total, 9))40.0
Test yourself
What is ?
- 2
- It diverges
The terms of a series go to 0. What can you conclude?
- It converges
- Its sum is 0
- Nothing yet, it may still diverge
- It diverges
Which series diverges?