Can you add forever?
The Greek philosopher Zeno of Elea (5th century BCE) posed a puzzle. To walk across a room 2 metres wide, you must first walk 1 metre, then half of the remaining metre, then half of what remains, and so on — infinitely many steps:
Infinitely many positive distances: surely they add up to an infinite distance, and you never arrive? Yet people cross rooms every day.
Adding long lists of numbers is much older than Zeno. Problem 79 of the Egyptian Rhind papyrus (about 1550 BCE) adds — seven houses, each with seven cats, each catching seven mice, and so on. Today the same arithmetic appears in savings that earn interest, in medicine doses that decay in the body, and in the decimal expansion of every number.
In this lesson we learn to add such lists — finite ones exactly, infinite ones by a limit — and find out when an infinite sum makes sense. Zeno's sum, we will prove, is exactly .
Running totals that settle down
A sequence is an infinite list of numbers, . A series is what you get by adding the terms one by one and keeping a running total. For Zeno's walk the running totals are
Each is short of by exactly the last step taken: The gap halves every time. It never becomes zero, but it becomes smaller than any distance you care to name — smaller than a millimetre after steps, smaller than the width of an atom after about . That is what we will mean by "the infinite sum is ": not that someone finishes infinitely many additions, but that the running totals close in on and on nothing else.
Definitions
Definition— sequence
A sequence of real numbers is a function that assigns a real number to each positive integer (sometimes to each ). We write it or A sequence may be given by a formula, such as , or recursively, by giving the first term(s) and a rule for each term in terms of earlier ones, such as , .
Definition— arithmetic and geometric sequences
A sequence is arithmetic if consecutive terms have a constant difference : , so with . It is geometric if consecutive terms have a constant ratio : , so .
Definition— summation notation
. The letter is a "dummy" index: and mean the same thing. For example .
Definition— limit of a sequence
A sequence converges to (or tends to ), written or , if for every tolerance there is an index such that for all . In words: eventually every term is within of , however small is. Otherwise the sequence diverges.
Definition— series and partial sums
Given a sequence , its partial sums are . The series converges to , and we write , if . If the partial sums have no limit, the series diverges.
So an infinite sum is not an infinite act of adding; it is the limit of finite sums. The limit laws you may know from Introductory calculus hold for sequences too: limits of sums, products and constant multiples are the sums, products and multiples of the limits.
Worked examples
Example— Arithmetic sequences
The seats in a stadium in Lagos are arranged so that the first row has seats and each row has more than the one in front: . Row has seats. By the formula proved below, the first rows hold seats: number of rows times the average of the first and last row.
Example— Geometric sequences
- A medicine with a half-life of one day: if mg are in the body today, then mg remain after days — a geometric sequence with ratio .
- Savings of rupees earning a year grow to rupees after years: ratio .
- has ratio : the signs alternate and the sizes double.
Example— A recursive sequence
The Tower of Hanoi puzzle has discs of different sizes on one of three pegs; you must move the whole stack to another peg, one disc at a time, never putting a larger disc on a smaller one. To move discs, you must move the top out of the way, move the largest disc, and move the back on top. So the least number of moves satisfies
giving The pattern suggests , and induction proves it: . Another famous recursion, , gives the sequence , studied by Indian scholars of poetic metre (Virahāṅka, Hemachandra) centuries before Fibonacci's rabbits (1202).
Example— Limits of sequences
- : given , choose ; then for .
- .
- diverges: its terms jump between and and stay apart, so they cannot all be within of a single number.
Explore: watching partial sums
The partial sums of Zeno's series , with the limit drawn as a dashed line:
1 + 1/2 + 1/4 + ⋯
How many terms until the partial sums are within 0.001 of 2?
- partial sums Sₙ
- terms aₙ
- Known sum
S20 = a1 + … + a20 = 1.999998
Known sum: L = 2 · still missing: L − S20 ≈ 0.000002
Partial sums on a screen are evidence, never proof: a series can look settled and still diverge, as the harmonic series does.
Now move the ratio . For which values do the partial sums of settle down? Try , , and .
The geometric series 1 + r + r² + ⋯
Add the terms one by one. Do the partial sums Sₙ settle down, or keep growing?
- partial sums Sₙ
- terms aₙ
S60 = a1 + … + a60 = 2
Partial sums on a screen are evidence, never proof: a series can look settled and still diverge, as the harmonic series does.
Finally the harmonic series . Switch on the logarithmic axis: the partial sums keep climbing, by about the same amount each time is multiplied by .
The harmonic series
The terms shrink to 0. Do the partial sums settle down?
- partial sums Sₙ
- terms aₙ
- ln n + γ
S1000 = a1 + … + a1000 = 7.485471
This is the harmonic series. Its partial sums grow without bound, but very slowly, like ln n + γ (γ ≈ 0.5772): S₁₀₀₀ ≈ 7.49, and Sₙ first passes 100 only after about 1.5 × 10⁴³ terms. The graph seems to level off; it never does.
Partial sums on a screen are evidence, never proof: a series can look settled and still diverge, as the harmonic series does.
Recursive sequences can be explored with a cobweb diagram. Iterating from any start gives a sequence converging to , the solution of . Iterating the logistic map instead can converge, oscillate or behave chaotically depending on — the start of the theory of dynamical systems.
Iterating the logistic map x ↦ r x (1 − x)
Try r = 2.8, 3.2, 3.5 and 3.9.
Iterates xₖ against k
- y = f(x)
- y = x
- cobweb path
Last iterates: x58 = 0.79946, x59 = 0.51304, x60 = 0.79946
The orbit appears to settle into a cycle of period 2: 0.513, 0.7995.
Fixed points in view (numerical): x* = 0 (repelling: |f′(x*)| > 1); x* = 0.6875 (repelling: |f′(x*)| > 1)
Based on 3,000 iterations in floating-point arithmetic: numerical evidence, not proof.
Finite sums
Theorem— Theorem 1 (arithmetic series)
The sum of the first terms of the arithmetic sequence is
Proof
Write the sum forwards and backwards and add the two lines term by term:
Each of the columns adds up to , so .
∎
With this gives . A famous story — probably embellished — tells that the young Gauss found this way in seconds.
Theorem— Theorem 2 (geometric series, finite)
If , then for every
Proof
Let . Then , and subtracting, every term except the first of and the last of cancels:
(This "telescoping" can also be proved by induction on : .) Divide by and multiply by .
∎
For the sum is simply .
Infinite series
To let in Theorem 2 we need to know what happens to .
Theorem— Lemma 3 (Bernoulli's inequality)
If , then for every .
Proof
Induction on . For : . If , then
∎
Theorem— Theorem 4 (powers of a small ratio)
If , then as .
Proof
If there is nothing to prove. Otherwise ; write with . By Lemma 3, , so
Given , choose ; then for all .
∎
Theorem— Theorem 5 (infinite geometric series)
Let . If , then
If , the series diverges.
Proof
Case . By Theorem 2 the -th partial sum is . By Theorem 4, , so .
Case . Then for every , so the terms do not tend to , and the series diverges by the term test (Theorem 6 below).
∎
Example— Zeno, 0.999… and repeating decimals
- : , , sum . Zeno's walker arrives.
- means : , , sum . So exactly: the partial sums fall short of by , which tends to .
- . Every repeating decimal is a geometric series, which is why it is a fraction (compare Real numbers and irrationality).
- : , sum .
Theorem— Theorem 6 (term test)
If converges, then . Equivalently: if the terms do not tend to , the series diverges.
Proof
Let . Then also (it is the same sequence, shifted by one place), so .
∎
The term test can only prove divergence. Terms tending to is necessary for convergence, but not sufficient — as the most famous series of all shows.
Theorem— Theorem 7 (the harmonic series diverges)
The partial sums satisfy for every . Hence grows without bound, and diverges, although .
Proof
Group the terms after the first into blocks that end at powers of :
The block has terms, each at least , so it adds up to at least . The first terms consist of the term and the blocks , so .
Given any number , choose ; then for all , because the partial sums increase. So is unbounded and cannot converge.
∎
The divergence is extraordinarily slow: first exceeds at and first exceeds only after more than terms. (In fact is close to ; see Exponential and logarithmic functions.) By contrast, squaring the denominators makes the series converge:
Theorem— Proposition 8 (the sum of 1/k² is less than 2)
For every : .
Proof
For , . Adding these for , the right-hand sides telescope:
(For the sum is .)
∎
The partial sums of increase and stay below ; the completeness of the real numbers (an increasing sequence that is bounded above converges) then guarantees that the series converges. Its sum, , was found by Euler in 1734 — the "Basel problem".
Series in Lean
In Mathlib a sequence is a function ℕ → ℝ, starting at index , and ∑ k ∈ range n, f k is — the first terms. HasSum f S means the series converges to , and Summable f that it converges to something.
First the finite sums: Theorem 1 and the telescoping of Theorem 2, both by induction, and the closed form (with Mathlib's version for comparison):
/-- **Sum of an arithmetic progression.** The first `n` terms of `a, a + d, a + 2d, …` add up to
`n(2a + (n − 1)d)/2`: "number of terms times the average of the first and last". Proved by
induction on `n`. -/
theorem arith_sum (a d : ℝ) (n : ℕ) :
∑ k ∈ range n, (a + k * d) = n * (2 * a + (n - 1) * d) / 2 := by
induction n with
| zero => simp
| succ m ih =>
rw [sum_range_succ, ih]
push_cast
ring/-- **The telescoping step.** `(1 − r)(1 + r + ⋯ + rⁿ⁻¹) = 1 − rⁿ`: multiplying by `1 − r`
makes every middle term cancel. Proved by induction on `n`. -/
theorem geom_telescope (r : ℝ) (n : ℕ) : (1 - r) * ∑ k ∈ range n, r ^ k = 1 - r ^ n := by
induction n with
| zero => simp
| succ m ih =>
rw [sum_range_succ, mul_add, ih, pow_succ]
ring/-- **Finite geometric sum.** For `r ≠ 1`, `a + ar + ⋯ + arⁿ⁻¹ = a(1 − rⁿ)/(1 − r)`:
divide the telescoping identity by `1 − r ≠ 0`. -/
theorem geom_sum (a r : ℝ) (hr : r ≠ 1) (n : ℕ) :
∑ k ∈ range n, a * r ^ k = a * (1 - r ^ n) / (1 - r) := by
have h1 : 1 - r ≠ 0 := sub_ne_zero.mpr (Ne.symm hr)
rw [← mul_sum, ← geom_telescope r n]
field_simp/-- The same sum in Mathlib's form `(rⁿ − 1)/(r − 1)`, from `geom_sum_eq`, which holds in every
division ring. -/
theorem geom_sum_library (r : ℝ) (hr : r ≠ 1) (n : ℕ) :
∑ k ∈ range n, r ^ k = (r ^ n - 1) / (r - 1) :=
geom_sum_eq hr nThe Tower of Hanoi recursion, as a Lean definition by pattern matching, and its closed form:
/-- The **Tower of Hanoi numbers**, defined recursively: no moves for `0` discs, and to move
`n + 1` discs, move `n` discs aside, move the largest disc, and move the `n` discs back on top:
`h(n + 1) = 2 h(n) + 1`. -/
def hanoi : ℕ → ℕ
| 0 => 0
| n + 1 => 2 * hanoi n + 1/-- **A closed form for the recursion:** `h(n) + 1 = 2ⁿ`, i.e. `h(n) = 2ⁿ − 1`. Induction:
`h(n + 1) + 1 = 2h(n) + 2 = 2(h(n) + 1) = 2 · 2ⁿ`. (Stated with `+ 1` to avoid natural-number
subtraction.) -/
theorem hanoi_formula (n : ℕ) : hanoi n + 1 = 2 ^ n := by
induction n with
| zero => rfl
| succ m ih =>
rw [hanoi, pow_succ, ← ih]
ringTheorem 5 for . Our proof combines the closed form with Mathlib's lemma that (Theorem 4, which we proved by hand above but do not re-prove in Lean):
/-- **Infinite geometric series.** If `|r| < 1`, the partial sums of `a + ar + ar² + ⋯` tend to
`a/(1 − r)`. The partial sum is `a(1 − rⁿ)/(1 − r)` (`geom_sum`), and `rⁿ → 0` when `|r| < 1`
(Mathlib's `tendsto_pow_atTop_nhds_zero_of_abs_lt_one`), so the partial sums tend to
`a(1 − 0)/(1 − r)`. -/
theorem geom_series_tendsto (a r : ℝ) (hr : |r| < 1) :
Tendsto (fun n => ∑ k ∈ range n, a * r ^ k) atTop (𝓝 (a / (1 - r))) := by
have hr1 : r ≠ 1 := by
intro h
rw [h, abs_one] at hr
exact lt_irrefl 1 hr
have hpow := tendsto_pow_atTop_nhds_zero_of_abs_lt_one hr
have hlim : Tendsto (fun n => a * (1 - r ^ n) / (1 - r)) atTop (𝓝 (a * (1 - 0) / (1 - r))) :=
((tendsto_const_nhds.sub hpow).const_mul a).div_const (1 - r)
rw [sub_zero, mul_one] at hlim
refine hlim.congr (fun n => ?_)
exact (geom_sum a r hr1 n).symm/-- The same result as a statement about the series: `Σ a rᵏ = a/(1 − r)` for `|r| < 1`. This
applies Mathlib's `hasSum_geometric_of_abs_lt_one` (the case `a = 1`) and multiplies by `a`. -/
theorem geom_series_hasSum (a r : ℝ) (hr : |r| < 1) :
HasSum (fun n => a * r ^ n) (a / (1 - r)) := by
rw [div_eq_mul_inv]
exact (hasSum_geometric_of_abs_lt_one hr).mul_left a/-- **`1 + 1/2 + 1/4 + 1/8 + ⋯ = 2`.** This applies Mathlib's `hasSum_geometric_two`. -/
theorem halves : HasSum (fun n : ℕ => (1 / 2 : ℝ) ^ n) 2 := hasSum_geometric_two/-- **`0.999… = 1`.** The decimal `0.999…` *means* the series `9/10 + 9/100 + 9/1000 + ⋯`, a
geometric series with first term `9/10` and ratio `1/10`. Its terms are positive, so it converges
to `S` exactly when its partial sums tend to `S`; and by `geom_series_tendsto` they tend to
`(9/10)/(1 − 1/10) = 1`. -/
theorem point_nine_recurring : HasSum (fun n : ℕ => (9 : ℝ) / 10 ^ (n + 1)) 1 := by
rw [hasSum_iff_tendsto_nat_of_nonneg (fun n => by positivity)]
have h := geom_series_tendsto (9 / 10) (1 / 10) (by rw [abs_of_pos (by norm_num)]; norm_num)
norm_num at h
refine h.congr (fun n => sum_congr rfl (fun k _ => ?_))
rw [pow_succ, div_pow, one_pow]
field_simpThe term test (from Mathlib), divergence for , and the harmonic series: Oresme's estimate, the unbounded growth of the partial sums, and the conclusion that terms tending to do not force convergence:
/-- **The term test.** If `Σ aₙ` converges, then `aₙ → 0`. Equivalently: if the terms do *not*
tend to `0`, the series diverges. This applies Mathlib's `Summable.tendsto_atTop_zero`. The
converse is false — see `harmonic_terms_tend_to_zero_but_diverges`. -/
theorem term_test {f : ℕ → ℝ} (h : Summable f) : Tendsto f atTop (𝓝 0) :=
h.tendsto_atTop_zero/-- **If `|r| ≥ 1`, then `Σ rⁿ` diverges.** Its terms satisfy `|rⁿ| = |r|ⁿ ≥ 1`, so they do not
tend to `0`, and the term test rules out convergence. (Mathlib:
`summable_geometric_iff_norm_lt_one`.) -/
theorem geom_diverges (r : ℝ) (hr : 1 ≤ |r|) : ¬ Summable (fun n : ℕ => r ^ n) := by
intro hs
have h0 : Tendsto (fun n : ℕ => |r ^ n|) atTop (𝓝 0) := by
simpa using (term_test hs).abs
-- Eventually `|rⁿ| < 1`, but every `|rⁿ| = |r|ⁿ ≥ 1`.
obtain ⟨N, hN⟩ := eventually_atTop.mp (h0.eventually (gt_mem_nhds zero_lt_one))
have hlt := hN N le_rfl
rw [abs_pow] at hlt
exact absurd (one_le_pow₀ hr) (not_le.mpr hlt)/-- **Oresme's estimate (c. 1350).** `1 + 1/2 + ⋯ + 1/2ⁿ ≥ 1 + n/2`. Group the terms:
the block `1/(2ᵐ + 1) + ⋯ + 1/2ᵐ⁺¹` has `2ᵐ` terms, each at least `1/2ᵐ⁺¹`, so it adds at least
`1/2`. Induction on `n` adds one block at a time. -/
theorem harmonic_two_pow (n : ℕ) :
1 + (n : ℝ) / 2 ≤ ∑ k ∈ range (2 ^ n), (1 : ℝ) / (k + 1) := by
induction n with
| zero => norm_num
| succ m ih =>
rw [pow_succ, mul_two, sum_range_add]
-- The new block: `2ᵐ` terms, each `≥ 1/2ᵐ⁺¹`.
have hblock : (1 : ℝ) / 2 ≤ ∑ x ∈ range (2 ^ m), (1 : ℝ) / ((2 ^ m + x : ℕ) + 1) := by
have hterm : ∀ x ∈ range (2 ^ m),
(1 : ℝ) / (2 ^ (m + 1)) ≤ (1 : ℝ) / ((2 ^ m + x : ℕ) + 1) := by
intro x hx
have hx' : x < 2 ^ m := mem_range.mp hx
apply one_div_le_one_div_of_le (by positivity)
have : (2 ^ m + x + 1 : ℕ) ≤ 2 ^ (m + 1) := by rw [pow_succ]; omega
exact_mod_cast this
calc (1 : ℝ) / 2 = ∑ _x ∈ range (2 ^ m), (1 : ℝ) / (2 ^ (m + 1)) := by
rw [sum_const, card_range, nsmul_eq_mul, pow_succ]
push_cast
field_simp
_ ≤ _ := sum_le_sum hterm
push_cast at hblock ih ⊢
linarith/-- **The harmonic partial sums grow without bound.** `Hₙ = 1 + 1/2 + ⋯ + 1/n` increases with
`n`, and `H_{2ᵐ} ≥ 1 + m/2` exceeds any given bound for large `m`. An increasing sequence that is
not bounded above tends to infinity. (Mathlib: `Real.tendsto_sum_range_one_div_nat_succ_atTop`.) -/
theorem harmonic_tendsto_atTop :
Tendsto (fun n => ∑ k ∈ range n, (1 : ℝ) / (k + 1)) atTop atTop := by
apply tendsto_atTop_atTop_of_monotone
· intro m n hmn
exact sum_le_sum_of_subset_of_nonneg (range_mono hmn) (fun _ _ _ => by positivity)
· intro b
obtain ⟨m, hm⟩ := exists_nat_gt (2 * b)
refine ⟨2 ^ m, le_trans ?_ (harmonic_two_pow m)⟩
linarith/-- **Terms tending to `0` do not guarantee convergence.** The terms `1/(n + 1)` of the harmonic
series tend to `0`, yet the series diverges: if it converged, its partial sums would tend to a
finite limit, but they tend to infinity (`harmonic_tendsto_atTop`). -/
theorem harmonic_terms_tend_to_zero_but_diverges :
Tendsto (fun n : ℕ => (1 : ℝ) / (n + 1)) atTop (𝓝 0) ∧
¬ Summable (fun n : ℕ => (1 : ℝ) / (n + 1)) := by
constructor
· exact tendsto_one_div_add_atTop_nhds_zero_nat
· intro hs
exact not_tendsto_nhds_of_tendsto_atTop harmonic_tendsto_atTop _ hs.hasSum.tendsto_sum_nat/-- The divergence of the harmonic series in Mathlib's form, `Real.not_summable_one_div_natCast`
(the `n = 0` term is `1/0 = 0` in Lean, which does not affect convergence). -/
theorem harmonic_not_summable_library : ¬ Summable (fun n : ℕ => (1 : ℝ) / n) :=
Real.not_summable_one_div_natCastA remark for the curious: Mathlib's HasSum asks for unconditional convergence (the sum must not depend on the order of the terms). For the series in this lesson — with terms of one sign, or geometric with — that agrees with the definition by partial sums used above. For a series like , whose partial sums converge (to ) but which can be rearranged to converge to anything, the two notions differ. Proposition 8 is not formalised here.
Partial sums, exactly and numerically
"""Geometric series in exact arithmetic: 1 + 1/2 + 1/4 + ... and 0.999...
With fractions the partial sums S_n = a(1 - r^n)/(1 - r) are computed with no
rounding, so we can watch the gap a/(1 - r) - S_n = a r^n/(1 - r) shrink
exactly: for 1 + 1/2 + 1/4 + ... the gap after n terms is 1/2^(n-1), and for
0.9 + 0.09 + 0.009 + ... it is 1/10^n. For |r| >= 1 the partial sums
oscillate or grow instead, and the terms do not tend to 0.
"""
from fractions import Fraction
def partial_sums(a, r, n):
"""[S_1, ..., S_n] for a + ar + ar^2 + ..., exact for Fractions."""
if n < 0:
raise ValueError("n must be non-negative")
sums, total, term = [], 0 * a, a
for _ in range(n):
total += term
sums.append(total)
term *= r
return sums
def closed_form(a, r, n):
"""a(1 - r^n)/(1 - r) for r != 1; n * a when r = 1."""
if r == 1:
return n * a
return a * (1 - r ** n) / (1 - r)
def gap(a, r, n):
"""a/(1 - r) - S_n, the part of the infinite sum still missing."""
return a / (1 - r) - closed_form(a, r, n)
def terms_needed(a, r, eps):
"""Smallest n with |a/(1 - r) - S_n| < eps (requires |r| < 1)."""
if not abs(r) < 1:
raise ValueError("needs |r| < 1")
n = 0
while abs(gap(a, r, n)) >= eps:
n += 1
return n
def main():
half, tenth = Fraction(1, 2), Fraction(1, 10)
print("1 + 1/2 + 1/4 + ... (a = 1, r = 1/2, limit 2)")
for n, s in enumerate(partial_sums(Fraction(1), half, 8), start=1):
print(f" S_{n} = {str(s):>7} gap = {str(2 - s)}")
print()
print("0.9 + 0.09 + 0.009 + ... (a = 9/10, r = 1/10, limit 1)")
for n, s in enumerate(partial_sums(Fraction(9, 10), tenth, 5), start=1):
print(f" S_{n} = {float(s):.{n}f} gap = 1 - S_{n} = {1 - s}")
print("The gap 1/10^n eventually drops below any positive number, so the")
print("limit of the partial sums, which is what 0.999... means, is exactly 1.")
print()
ok = all(
partial_sums(Fraction(3), r, 30)[-1] == closed_form(Fraction(3), r, 30)
for r in (half, -half, Fraction(2, 3), Fraction(-9, 10), Fraction(5))
)
print(f"Closed form a(1 - r^n)/(1 - r) agrees with term-by-term sums: {ok}")
need = terms_needed(Fraction(1), half, Fraction(1, 10 ** 6))
print(f"Terms of 1 + 1/2 + ... needed to come within 10^-6 of 2: {need}")
print()
for r in (1, -1, 2):
sums = partial_sums(1, r, 8)
print(f"r = {r:2d}: partial sums {sums} - no limit")
print()
print("Epistemic status: exact rational arithmetic for finitely many n;")
print("the closed form and the limits are proved in the lesson (and in")
print("Lean); a table of partial sums can only illustrate convergence.")
if __name__ == "__main__":
main()The exact gaps and are the "error terms" of Theorem 5's proof, made visible. But a table of finitely many partial sums never proves convergence: it is the formula, valid for every , together with , that does.
"""The harmonic series: terms that shrink to 0, sums that never stop growing.
Oresme's grouping says the block 1/(2^k + 1) + ... + 1/2^(k+1) is at least 1/2;
we compute these blocks exactly with fractions. Then, with 40-digit decimal
arithmetic, we find the first n with H_n = 1 + 1/2 + ... + 1/n > t for
t = 1, ..., 10 (H_n first exceeds 10 at n = 12367) and compare H_n with
ln n + 0.5772 (Euler's constant). By contrast, 1 + 1/4 + 1/9 + ... stays
below 2.
"""
import math
from decimal import Decimal, localcontext
from fractions import Fraction
#: Euler's constant gamma, to 16 digits (used only for comparison).
EULER_GAMMA = 0.5772156649015329
def oresme_block(k):
"""1/(2^k + 1) + ... + 1/2^(k+1), exactly (2^k terms)."""
if k < 0:
raise ValueError("k must be non-negative")
return sum(Fraction(1, j) for j in range(2 ** k + 1, 2 ** (k + 1) + 1))
def harmonic_exact(n):
"""H_n = 1 + 1/2 + ... + 1/n as a Fraction (for small n)."""
return sum((Fraction(1, j) for j in range(1, n + 1)), Fraction(0))
def first_exceeding(targets):
"""For each target t (increasing), the least n with H_n > t.
Uses Decimal with 40 significant digits: after 10^5 additions the
accumulated rounding error is far below the gaps 1/n near the answers.
"""
answers = []
with localcontext() as ctx:
ctx.prec = 40
total, n = Decimal(0), 0
for t in targets:
while total <= t:
n += 1
total += Decimal(1) / n
answers.append(n)
return answers
def basel_partial(n):
"""1 + 1/4 + ... + 1/n^2 in floating point (math.fsum)."""
return math.fsum(1.0 / (j * j) for j in range(1, n + 1))
def main():
print("Oresme's blocks (exact): each block of 2^k terms is at least 1/2")
for k in range(5):
block = oresme_block(k)
terms = f"1/{2 ** k + 1} + ... + 1/{2 ** (k + 1)}" if k else "1/2"
print(f" k = {k}: {terms} = {float(block):.4f}"
f" >= 1/2: {block >= Fraction(1, 2)}")
print("So H(2^m) >= 1 + m/2: the partial sums pass every bound.")
print()
targets = list(range(1, 11))
print("t first n with H_n > t ln n + gamma")
for t, n in zip(targets, first_exceeding(targets)):
print(f"{t:2d} {n:12d} {math.log(n) + EULER_GAMMA:.4f}")
print("The terms 1/n tend to 0, yet the sums still reach any height -")
print("it takes roughly e^(t - 0.58) terms to reach height t.")
print()
for n in [10, 1000, 100000]:
print(f"1 + 1/4 + ... + 1/{n}^2 = {basel_partial(n):.6f} (< 2)")
print(f"pi^2/6 = {math.pi ** 2 / 6:.6f}, Euler's value of the whole sum")
print()
print("Epistemic status: the blocks are exact for k <= 4 (the lesson")
print("proves the bound for all k); the first-exceeding table uses")
print("40-digit decimals, numerical but with error far below 1/n; the")
print("ln n + gamma column is an approximation. No finite table proves")
print("divergence: the grouping argument does.")
if __name__ == "__main__":
main()The harmonic experiment shows why evidence can mislead in both directions. After terms the sum has only just passed , and it creeps upward so slowly that a computer adding a billion terms a second would need longer than the age of the universe to pass . A computer alone could never show that the series diverges; Oresme's grouping argument does it in four lines.
Exercises
1. Sequences and series
Warm-upHumanFind the sum of the first terms of the arithmetic sequence
2. Sequences and series
Warm-upHumanCompute (ten terms).
3. Sequences and series
Warm-upHumanA sequence is defined by and . What is ?
4. Sequences and series
CoreHumanWhich of these infinite series converge? (Choose all that apply.)
5. Sequences and series
CoreHumanWrite as a geometric series and find its sum in lowest terms. Enter .
6. Sequences and series
CoreHumanA student argues: "The terms tend to , so by the term test converges." What is wrong?
7. Sequences and series
StretchHumanIn the proof that the harmonic series diverges, why is ?
8. Sequences and series
CoreFormalIn Lean, HasSum f S means "the series converges to ". Which statement formalises ?
9. Sequences and series
StretchComputationalWrite terms_needed(a, r, eps) for and : the smallest such that the partial sum is within eps of the limit . Use Fraction for exact arithmetic (the tests pass fractions). By Theorem 5 the gap is .
Common misconceptions
Misconception
"If the terms tend to , the series converges." The harmonic series has terms tending to and diverges. Terms tending to is necessary for convergence (Theorem 6), but not sufficient.
Misconception
"An infinite sum of positive numbers must be infinite." . What matters is how fast the terms shrink: geometrically shrinking terms add up to a finite total.
Misconception
" is slightly less than ." is the geometric series , whose sum is exactly . There is no real number strictly between and : any gap would have to be smaller than for every , hence .
Misconception
" for every ." Only for . For the formula would give , which is nonsense for real numbers: the partial sums grow without bound. The finite formula is valid for all ; the infinite one needs .
Misconception
"A sequence converges if its terms get closer together." has consecutive differences , yet . Convergence is about getting close to a fixed limit, not just to the next term.
Other ways of seeing
Geometry— Self-similar pictures
Geometric series describe self-similar shapes. In the figure above, the square minus its left half is a half-size copy of a familiar shape, and the series records the copies. The Koch snowflake — repeatedly add an equilateral bump to the middle third of every edge — has perimeter multiplied by at every stage, so its perimeter is infinite (), while the areas of the bumps form a geometric series with ratio , so its area is finite: of the starting triangle.
Probability— Waiting for heads
Toss a fair coin until it lands heads. The probability that the first head comes on toss is , and these probabilities add up to — as total probability must. The expected number of tosses is , a sum one can find by differentiating the geometric series term by term. Infinite series are the language of probability with infinitely many outcomes.
Number theory— Decimals, and a world where 1 + 2 + 4 + ⋯ = −1
Every decimal is the series , and the theory of geometric series is exactly why repeating decimals are fractions. Number theorists also measure size differently: in the -adic numbers a number is "small" when it is divisible by a high power of , so ! There the geometric series formula holds for and is a genuine theorem. This is not a trick about real numbers — in that series diverges — but a different notion of distance, and -adic numbers are central in modern number theory.
Analysis— Convergence without knowing the limit
The definition of convergence needs the limit in advance. Cauchy found a test that does not: a sequence converges if and only if its terms eventually stay arbitrarily close to each other ( for all large ). That this works is equivalent to the completeness of , the property that also makes increasing bounded sequences converge, as used for . Series whose signs alternate bring new subtleties: converges to , but Riemann proved that its terms can be rearranged to converge to any number you like. See Real analysis.
History and global context
- Ancient sums. The Egyptian Rhind papyrus (about 1550 BCE) adds the geometric sequence . Zeno of Elea's paradoxes (5th century BCE) raised the question of infinite sums. Archimedes (3rd century BCE) summed to find the area of a parabolic segment, by an argument that avoided the infinite through a double reductio ad absurdum.
- India. Āryabhaṭa (499 CE) gave rules for arithmetic series and for the sums of squares and cubes. Writers on Sanskrit prosody, from Virahāṅka to Hemachandra (about 1150), counted poetic metres with the recursion now called Fibonacci's. In the 14th century, Mādhava of Saṅgamagrāma and the Kerala school found infinite series such as .
- Europe. Nicole Oresme proved the divergence of the harmonic series around 1350, by the grouping in Theorem 7. Pietro Mengoli asked for the sum of in 1650, and Leonhard Euler found in 1734. Augustin-Louis Cauchy's Cours d'analyse (1821) gave the modern definition of convergence through limits of partial sums.
Further reading
- Richard Courant and Herbert Robbins, What Is Mathematics? (1941), chapter VI, on functions and limits.
- William Dunham, Journey Through Genius (1990) — chapters on the harmonic series and Euler's solution of the Basel problem.
- Julian Havil, Gamma: Exploring Euler's Constant (2003) — everything about .
- Stephen Abbott, Understanding Analysis (2001), chapter 2 — the rigorous next step on sequences and series.
- Konrad Knopp, Theory and Application of Infinite Series (1922; English translation 1928) — the classic reference.