The Power Series
A power series is a polynomial that never ends: Whether it adds up to a finite number depends on . This lesson shows what a power series is, why it converges for some and not others (the radius of convergence), and how computers use them to evaluate functions. It stays at the level of tables and intuition; calculus fills in the proofs.
A polynomial with infinitely many terms
A power series in has the form
The numbers are the coefficients. For each value of the power series becomes an ordinary infinite series of numbers, which may converge or diverge. So a power series defines a function on the set of where it converges.
The simplest example has every coefficient equal to 1:
It is a geometric series with ratio , so it converges exactly when . Inside that interval, the infinite polynomial and the function are the same thing.
def partial(x, N):
return sum(x**n for n in range(N + 1))
for x in [0.5, -0.5, 0.9, 1.1]:
sums = [partial(x, N) for N in (5, 20, 80)]
target = 1 / (1 - x)
print(f"x = {x:>4}: N=5 {sums[0]:9.4f} N=20 {sums[1]:9.4f} N=80 {sums[2]:12.4f} 1/(1-x) = {target:.4f}")x = 0.5: N=5 1.9688 N=20 2.0000 N=80 2.0000 1/(1-x) = 2.0000
x = -0.5: N=5 0.6562 N=20 0.6667 N=80 0.6667 1/(1-x) = 0.6667
x = 0.9: N=5 4.6856 N=20 8.9058 N=80 9.9980 1/(1-x) = 10.0000
x = 1.1: N=5 7.7156 N=20 64.0025 N=80 22522.4024 1/(1-x) = -10.0000
Near the centre () a handful of terms is enough. Near the edge () you need many terms. Outside () the partial sums explode, even though the formula still has a value there: the series simply does not represent the function outside its interval.
Radius of convergence
Every power series converges in a symmetric interval around its centre, and diverges outside it. The half-width is the radius of convergence:
- : the series converges,
- : the series diverges,
- : the endpoints must be checked one by one.
The ratio test finds . Apply it to the terms : the ratio is . If , the series converges when , so .
| Series | Coefficient ratio → | Interval | |
|---|---|---|---|
| 1 | 1 | ||
| 2 | |||
| 0 | all | ||
| 0 | only | ||
| () | 1 | 1 |
The last row shows an endpoint surprise: at it is the divergent harmonic series, at it is the convergent alternating harmonic series.
Centred somewhere else
A power series can be centred at any point , using powers of :
Its interval of convergence is . Centring the series where you care about the function keeps the important terms small, which is why approximations are built around a convenient point.
In software: evaluating functions
Hardware can only add, subtract, multiply and divide. To compute , or , libraries use polynomials, which are truncated power series (or close relatives tuned for accuracy). The series for is with , and the factorials make it converge very fast near 0:
import math
def exp_series(x, terms):
total, term = 0.0, 1.0
for n in range(terms):
total += term
term *= x / (n + 1) # next term from the previous one: x^(n+1)/(n+1)!
return total
for terms in [3, 6, 10, 15, 20]:
approx = exp_series(1.0, terms)
print(f"{terms:>2} terms: {approx:.15f} error {abs(approx - math.e):.1e}") 3 terms: 2.500000000000000 error 2.2e-01
6 terms: 2.716666666666666 error 1.6e-03
10 terms: 2.718281525573192 error 3.0e-07
15 terms: 2.718281828458230 error 8.1e-13
20 terms: 2.718281828459046 error 4.4e-16
Two programming habits show up here: each term is built from the previous one (no factorials or big powers recomputed), and the loop stops after a fixed count. Real libraries also reduce the argument first (for example , or using its period), so the series is only ever evaluated near 0, where it converges fastest.
The next lesson builds the series for , , and . For the rigorous theory see Power Series and Power Series in depth.
Exercises
Exercise 1: Sum a power series
What function does equal, and for which ?
Answer
for .
Solution
Exercise 2: Radius by the ratio test
Find the radius of convergence of and .
Answer
and .
Solution
Exercise 3: Centred series
The series is geometric. Find its interval of convergence and its sum.
Answer
, sum .
Solution
x = 2.5
print(sum((x - 2)**n for n in range(60)), 1 / (3 - x))2.0 2.0
Exercise 4: How many terms?
Using exp_series from the lesson (or your own loop), find the smallest number of terms for which the series for is within of math.exp(2).
Answer
14 terms (powers to ).
Solution
The first omitted term is roughly the error, and while , so about 14 terms are needed.
import math
total, term, n = 0.0, 1.0, 0
while abs(total - math.exp(2)) >= 1e-6:
total += term
n += 1
term *= 2 / n
print(n, total)14 7.389055882389215
Test yourself
Where does converge?
- For all
- For
- For
- Only at
What is the radius of convergence of ?
- 0
- 1
- Infinite
A power series has radius and is centred at . Which is certainly inside its interval of convergence?