taylorexamples.mw

Taylor Series Examples

Math 1352

In these pages, we'll take advantage of the computer to do some animations to show convergence of Taylor Series.  We're using the computer algebra package Maple, but if you concentrate on the math and the graphs, you won't have to know Maple.

Example 1

 > with(plots): with(plottools):

Warning, the name arrow has been redefined

Warning, the name arrow has been redefined

Let's start with an example where we know the Taylor series converges to the function everywhere.  Let's use

 > f := sin(x);

and center the series at a = 0.    Fortunately, Maple knows how to compute partial sums of the taylor series.

 > p0:=taylor(f,x=0,1);

 > p1 := taylor(f,x=0,2);

 > p3 := taylor(f,x=0,3);

 > p4 := taylor(f,x=0,4);

In Maple, we have to do something to get rid of that stuff at the end and make it a real polynomial

 > p4;

 > p4 := convert(p4, polynom);

Here are the first 36 Taylor polynomials

 > for n from 1 to 36 do p[n]:=convert(taylor(f,x=0,n),polynom); od;

 >

Notice the odd numbered ones don't add any new terms, so lets exclude them

 > for k from 1 to 18 do q[k]:=convert(taylor(f,x=0,2*k),polynom); od;

 >

Here is a plot of our function over serveral periods

 > bp := plot(f, x=-4*Pi..4*Pi,y=-3..3, color=blue): bp;

 >

Now lets do an animation where we plot succesive partial sums of the taylor series on the graph above.

 > for k from 1 to 18 do pl[k]:=display([bp, plot(q[k],x=-4*Pi..4*Pi, numpoints=200, title=cat("order = ", convert(degree(q[k],x),string)))]); od:

 > display([seq(pl[k], k=1..18)], insequence=true, view=[-4*Pi..4*Pi,-3..3]);

What happens if we look at this animation over a larger range, say to ?  It's easy to check:

 > bbp := plot(f, x=-6*Pi..6*Pi, y=-3..3, color=blue): bbp;

 > for k from 1 to 18 do pl[k]:=display([bbp, plot(q[k],x=-6*Pi..6*Pi, numpoints=200, title=cat("order = ", convert(degree(q[k],x),string)))]); od:

 > display([seq(pl[k], k=1..18)], insequence=true, view=[-6*Pi..6*Pi,-3..3]);

Example 2

Let's consider the case where the series only has a finite radius of convergence.   So, let's consider arctan(x), with the series centered at 0

 > maxn := 36;

 > f := arctan(x);

 > bp:=plot(f, x=-1.5..1.5,color=blue): bp;

 > for n from 1 to maxn do p[n]:=convert(taylor(f,x=0,n),polynom); od;

 >

Again, we only need the polynomials with even indices.

 > maxk:=maxn/2;

 > for k from 1 to maxk do q[k]:=convert(taylor(f,x=0,2*k),polynom); od;

 >

The form of the series is

 > s:=Sum((-1)^m*x^(2*m+1)/(2*m+1),m=0..infinity);

The absolute value of the mth term is

 > a := m -> abs(x)^(2*m+1)/(2*m+1);

 > a(m);

 >

Apply the ratio test

 > rat := a(m+1)/a(m);

 > rat := simplify(rat);

 > r := limit(rat, m=infinity);

 > solve(r<1,x);

 >

i.e., the open interval (-1,1) is the interval of convergence, and the radius of convergence is one.   Thus, we can't expect the series to converge to the function outside the interval [-1,1].  It might or might not converge to the function at the endpoints -1 and 1.  See what you think.  Here is the animation

 > for k from 1 to 18 do pl[k]:=display([bp, plot(q[k],x=-1.5..1.5, numpoints=200, title=cat("order = ", convert(degree(q[k],x),string)))]); od:

 > display([seq(pl[k], k=1..18)], insequence=true, view=[-1.5..1.5, -2..2]);

Let's examine what happens near the right-hand endpoint more closely.

 > bpp := plot(f, x=0.9..1.1, color=blue, view=[0.9..1.1, 0..1.2]): bpp;

 > for k from 1 to 18 do pl[k]:=display([line([1,0],[1,2], color=green),bpp, plot(q[k],x=0.9..1.1, numpoints=200, title=cat("order = ", convert(degree(q[k],x),string)))]); od:

 > display([seq(pl[k], k=1..18)], insequence=true, view=[0.9..1.1, 0..1.2]);

 >

 >