This notebook illustrates use of Mathematica to investigate convergence of infinite series of constants. To see the result of a command, position the cursor (I-beam) at its end and hit Enter on the numeric keypad, or type Shift-Return or Command (ýÿ)-Return on the main part of the keyboard.
Finite series. Mathematica can easily calculate the sum of a finite number of terms of a sequence. Just specify the defining formula for the terms and how many terms to add. The following command, for example, evaluates 1 + +⋯ +
NSum[1/2^n, {n, 0, 100}]
As in the True BASIC program SerieSum, the dot in the output after the number 2 indicates that the sum has been rounded off. Use of the Sum command instead of NSum directs Mathematica to calculate the sum of the rational numbers in the series. It then expresses the answer in rational form, that is, as the quotient of two integers. Try the following, and note the size of the numerator and the denominator! Such output is usually much less convenient than the decimal output from NSum.
Sum[1/2^n, {n, 0, 100}]
Infinite series. Mathematica will also accept Infinity (or the symbol ∞ from its Basic Input palette, which you can choose from the Palettes entry of the File menu) as the last entry of a range specification of n from k to l in an expression {n, k, l}. The following two commands illustrate this for the series
NSum[1/2^n, {n, 0, Infinity}]
NSum[1/2^n, {n, 0, ∞}]
How does Mathematica do it? It uses a summation technique much more efficient than the brute-force addition programmed into SerieSum. The technique is known as the Wynn epsilon algorithm in numerical analysis. It is a more refined version of ideas in the subsection Estimating the Sum of a Series in Section 12.3 of J. Stewart, Calculus, 4th Edition, Brooks/Cole, 1999.
Here is what Mathematica does with the series from Exercise 20 of Section 12.3 in Stewart's text: , for which SerieSum calculates 0.35632 (rounded to five decimal places) as the sum of the first ten thousand terms.
How good is Mathematica at this? One way to test that is to ask it to sum the divergent Harmonic series! The nth term tends to zero as n approaches ∞, so successively calculated partial sums become very close, perhaps close enough to fool a computer?
Mathematica's programmers have built in enough checking at least to warn the user that the output 23953.7 is suspect! (Per the earlier comment about the methods in Section 12.3, note the references to integration.) As always, the moral here is how dangerous it is to place unquestioning confidence in a digital wizard!