28. Infinite series and partial sums

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

Adding infinitely many numbers sounds like it should always produce infinity — or nonsense. It doesn't, always: some infinite sums settle on a perfectly ordinary finite number. Making sense of when and why is what the rest of this module is about, and it starts by reducing "infinite sum" to something already built in §7.0 and §7.1: a sequence, and its limit.

Series as a sequence of partial sums

An infinite series is a sum \displaystyle\sum_{n=1}^\infty a_n. Define its Nth partial sum as the ordinary, finite sum of the first N terms:

S_N=\sum_{n=1}^Na_n=a_1+a_2+\cdots+a_N

The partial sums S_1,S_2,S_3,\ldots form an ordinary sequence — and the series is defined to converge exactly when that sequence does:

\sum_{n=1}^\infty a_n=\lim_{N\to\infty}S_N

This is the entire idea of the module, stated in one line: an infinite sum is nothing but the limit of a sequence you already know how to analyze. Every tool from §7.0 and §7.1 — limit laws, the Monotone Convergence Theorem — applies to S_N directly. If \lim_{N\to\infty}S_N exists and is finite, the series converges to that value; if the limit doesn't exist (including going to \pm\infty), the series diverges.

A first example, watched numerically

\sum_{n=1}^\infty\frac1{2^n}=\frac12+\frac14+\frac18+\cdots

The partial sums here happen to have a clean closed form, S_N=1-\frac1{2^N} (verify: S_1=1-\frac12=\frac12 ✓, and each new term \frac1{2^{N+1}} exactly halves the remaining gap to 1). As N\to\infty, \frac1{2^N}\to0, so:

\sum_{n=1}^\infty\frac1{2^n}=\lim_{N\to\infty}\left(1-\frac1{2^N}\right)=1

An infinite sum of infinitely many positive numbers, totalling exactly 1 — not "close to 1," not "approaching 1 forever without arriving," but equal to 1, in the same sense that \lim_{n\to\infty}\frac1n equals exactly 0. (§7.4 turns this exact series into the resolution of one of Zeno's paradoxes.)

Series that clearly diverge, and one that's deceptive

\displaystyle\sum_{n=1}^\infty1=1+1+1+\cdots has S_N=N, which grows without bound — obviously divergent.

The harmonic series, \displaystyle\sum_{n=1}^\infty\frac1n, is the deceptive one. Its terms shrink toward 0, exactly like the convergent \sum\frac1{2^n} above — but unlike that series, its partial sums grow without bound, just extremely slowly. This is surprising enough, and important enough, that §7.5 is devoted entirely to proving it.

Doing it in Python

Partial sums of \sum\frac1{2^n}, confirming they climb toward 1 without ever reaching it:

from fractions import Fraction

print(f"{'N':>3} {'S_N (exact)':>14} {'S_N (decimal)':>15}")
for N in range(1, 7):
    S_N = sum(Fraction(1, 2**n) for n in range(1, N + 1))
    print(f"{N:>3} {str(S_N):>14} {float(S_N):>15.6f}")

Partial sums of the harmonic series — growing, but so slowly that it's easy to mistake for convergence over a small range of N:

from fractions import Fraction

print(f"{'N':>5} {'S_N':>12}")
for N in (1, 5, 10, 20):
    S_N = sum(Fraction(1, n) for n in range(1, N + 1))
    print(f"{N:>5} {float(S_N):>12.6f}")
print("\nkeeps climbing -- module 7.5 proves it never stops")

Partial sums of \sum\frac1{n^2} — the Basel problem, famously summing to \frac{\pi^2}6, watched converging numerically:

import math

print(f"{'N':>6} {'S_N':>10} {'pi^2/6':>10}")
for N in (10, 100, 1000, 10000):
    S_N = sum(1 / n**2 for n in range(1, N + 1))
    print(f"{N:>6} {S_N:>10.6f} {math.pi**2/6:>10.6f}")

Worked example

Determine whether \displaystyle\sum_{n=1}^\infty(-1)^{n+1} converges, by examining its partial sums directly.

Write out the terms: 1,-1,1,-1,1,-1,\ldots

S_1=1,\quad S_2=1-1=0,\quad S_3=0+1=1,\quad S_4=1-1=0,\quad\ldots

The partial sums alternate forever between 1 and 0 — they never settle on a single value.

\boxed{\text{diverges (by oscillation of the partial sums)}}

Sanity check. This is the same flavor of divergence as (-1)^n itself in §7.0 — a sequence (here, of partial sums) that oscillates between two values has no limit, by definition. Notice something important: the terms a_n=(-1)^{n+1} do not shrink to 0 — they stay exactly \pm1 forever. That turns out to be exactly why this series must diverge, which §7.5 makes precise and general.

Your turn

1. Find a formula for the partial sum S_N of \displaystyle\sum_{n=1}^\infty\frac1{3^n}, then find the series' sum.

2. Does \displaystyle\sum_{n=1}^\infty n converge or diverge? Determine this directly from S_N.

3. True or false: if a series' terms a_n shrink toward 0, the series must converge.

Solutions

1. Following the same pattern as \sum\frac1{2^n}: S_N=\frac12\left(1-\frac1{3^N}\right) (each new term now closes a third of the remaining gap rather than a half — check S_1=\frac12\cdot\frac23=\frac13 ✓). As N\to\infty, \frac1{3^N}\to0:

\sum_{n=1}^\infty\frac1{3^n}=\lim_{N\to\infty}\frac12\left(1-\frac1{3^N}\right)=\boxed{\frac12}

2. S_N=1+2+\cdots+N=\frac{N(N+1)}2 (the familiar triangular-number formula). As N\to\infty, S_N\to\inftydiverges, and obviously so, since the terms themselves grow without bound rather than shrinking.

3. False. This is precisely the harmonic series' lesson: its terms \frac1n\to0, yet the series diverges. Terms shrinking to zero is necessary for convergence but not sufficient — a fact important enough to be its own named test in §7.5, and the harmonic series is the standard counterexample cited whenever someone is tempted to think "terms go to zero" is the whole story.

Check yourself in code

Compute the exact partial sum S_N of \sum\frac1{2^n} for N=1,2,3,4,5,6 as fractions.

Print exactly this:

  1            1/2       0.500000
  2            3/4       0.750000
  3            7/8       0.875000
  4          15/16       0.937500
  5          31/32       0.968750
  6          63/64       0.984375
from fractions import Fraction

for N in range(1, 7):
    S_N = sum(Fraction(1, 2**n) for n in range(1, N + 1))
    # print N, S_N as a fraction, and S_N as a decimal, right-aligned
    print(...)
from fractions import Fraction

for N in range(1, 7):
    S_N = sum(Fraction(1, 2**n) for n in range(1, N + 1))
    print(f"{N:>3} {str(S_N):>14} {float(S_N):>14.6f}")

An infinite series is defined as the limit of its sequence of partial sums, \sum a_n=\lim_{N\to\infty}S_N — which means every idea already built for sequences (limit laws, the Monotone Convergence Theorem) transfers directly. Terms shrinking toward zero is a necessary condition for convergence, as the oscillating \sum(-1)^{n+1} shows by failing it outright, but the harmonic series proves it is not sufficient — a subtlety significant enough that §7.5 is built entirely around resolving it.

Next: the one family of series where the partial-sum formula can always be found in closed form — geometric series — plus a second family, telescoping series, where nearly every term cancels.