Experimenting with power series

1. Computing coefficients of power series

Say, we want to compute the power series of f, centered at center up to the term x^max...

f = Exp[x];
center = 0;
max = 10;

...then we can use the following Mathematica command:

Series[f, {x, center, max}]

2. Plotting partial sums

We first define the nth term of a power series as a function of n:

coeff[n_] := x^n/n!;

The following function produces the respective partial sum, with terms up to n=t:

partialsum[t_] := Sum[coeff[n], {n, 0, t}];

For example...

partialsum[20]

Now we're ready to plot:

Plot[partialsum[10], {x, -10, 10}]

3. Evaluating partial sums

To evaluate a partial sum for a certain value of x, we use Mathematica's substitute command:

partialsum[10] /. x -> 1

To check the accuracy, the command N (for "numerical") is often useful; the second argument specifies how many digits are being computed:

N[%, 20]