Power Series Approximation
Based on the Power Series Approximation worksheet (vfpowerapprox.nb) by Corinne Manogue
© Corinne Manogue 2005; available at http://physics.oregonstate.edu/ph320/vfpowerapprox.nb.

(Note: if you used my worksheet as a basis for your homework, you need to give me credit!)

This Mathematica worksheet explores the use of power series to approximate the function f(z)= (1/(1+(z^2))).
I do not expect you to use Mathematica code as sophisticated as what appears below, but I am trying to model for you some additional commands you can learn as you go along.  As a minimum, you should plot 3 or 5 different approximations for f(z)= (1/(1+(z^2))), and compare the region of convergence that you get from the substitution theorem with what appears to be happening in the graphs.

First, we define and plot f(z).

SetOptions[Plot,PlotStyle->Thickness[0.01]];

f=(1/(1+(z^2)));
Plot[f,{z,-3,3}]

Using the substitution theorem, use the formula for (((1+ϵ))^p) with ϵ=(z^2) and p=-1.  Then the coefficients of the odd powers are zero (not surprising; this is an even function!) and the coefficients of the even powers alternate between 1 and -1.  This substitution series is valid for |ϵ|<1 and therefore for | z | < 1.

Zeroth order (n=0) term:

c[0]=f/.z->0
g=c[0];

The function g(z) is the approximation to f(z).  The purple line is the approximation and the blue line is the function f(z).

Plot[{f,g},{z,-3,3}]

g(z) is only a good approximation for f(z) at z=0.

Note: the first order term is zero:

c[1]=D[f,z]/.z->0

Higher order terms:

nmax=20;

Here is a loop to calculate the first 20 nonzero coefficients:

Do[c[n]=(((-1))^(n/2)),{n,0,nmax,2}];
Do[c[n]=0,{n,1,nmax,2}];

Second order (n=2):

g:=c[0]+c[2](z^2)
Plot[{f,g},{z,-3,3},PlotRange->{-2,1},AspectRatio->Automatic]

For what values of z is g(z) a good approximation for f(z)=(1/(1+(z^2)))?

Fourth order (n=4):

g:=c[0]+c[2](z^2)+c[4](z^4);
Plot[{f,g},{z,-3,3},PlotRange->{0,2}]

For what values of z is g(z) a good approximation for f(z)=(1/(1+(z^2)))?

Higher order (n=nmax):

g=Sum[c[n](z^n),{n,0,nmax}];
Plot[{f,g},{z,-3,3},PlotRange->{0,2}]

The series is always a perfect fit at the point we are expanding around, in this case z=0.  As more and more terms are added to the series approximation (by increasing nmax -- try it!), the approximation becomes a better fit to the function, closer and closer to z=-1 and z=1.  But the approximation never "settles down" to a limit for values of z such that 1<|z|.  This is what it means for a series to diverge for these values of z.

Mathematica can also calculate the power series directly; for further information, look up the "Series" command.

g=Normal[Series[f,{z,0,20}]]