Lesson 5 of 15

Infinite Series

Infinite Series

An infinite series is the sum of the terms of a sequence:

n=1an=a1+a2+a3+\sum_{n=1}^{\infty} a_n = a_1 + a_2 + a_3 + \cdots

Partial Sums

The (N)-th partial sum is:

SN=n=1NanS_N = \sum_{n=1}^{N} a_n

A series converges if the sequence of partial sums ((S_N)) converges. The limit is the sum of the series.

Geometric Series

The geometric series (\sum_{n=0}^{\infty} r^n) converges to (\frac{1}{1-r}) when (|r| < 1).

For example, (\sum_{n=0}^{\infty} (1/2)^n = 2).

Harmonic Series

The harmonic series (\sum_{n=1}^{\infty} 1/n) diverges -- the partial sums grow without bound, even though the terms go to zero.

The Divergence Test

If (\lim_{n \to \infty} a_n \ne 0), then (\sum a_n) diverges. (The converse is false -- the harmonic series is a counterexample.)

Your Task

Implement:

  1. partial_sum(f, N) -- computes (\sum_{n=1}^{N} f(n))
  2. partial_sums(f, N) -- returns a list ([S_1, S_2, \ldots, S_N])
Pyodide loading...
Loading...
Click "Run" to execute your code.