Taylor Series
18 November 1996

We have already discussed the idea of a Taylor polynomial.  

A Taylor series can be thought of as an unending Taylor polynomial.  

We can compute the value of any Taylor polynomial at any point x, but when we try to do the same thing for a Taylor series, we will have to add up and infinite number of terms, and we don't even know if the sum will converge to a particular value.

If the sum converges, we would like to know if it converges to the original function f(x) which we were approximating.

We will find that the answer is often:

  yes, for any x, the series converges, and it converges to f(x)
  
but sometimes:

  yes and no, - the series only converges to f(x) for values of x near the defining point x=c.
  
It is actually possible for a Taylor series to converge but not to f(x) - we won't worry too much about that possibility.

Let's enter the plottaylor command (from Lab 9):

Clear[plottaylor]
plottaylor[f_,{x_,x0_,n_,m_},{a_,b_}]:=
   Block[ {taylor, k,y },
   Do[ 
     taylor[y_,k]=Normal[ Series[ f/.x->y,{y,x0,k}] ];
     Plot[ {f,taylor[x,k]},{x,a,b},
        PlotStyle->{RGBColor[1.000, 0.069, 0.116],
        RGBColor[0.177, 0.150, 1.000]}], {k,1,n,m}] ]

Example 1
f(x)=E^x

plottaylor[E^x,{x,0,5,1},{0,2}]

Example 2
f(x)=Sin(x)

You might think sin(x) would be hard to approximate.  It has an infinite number of zeroes, whereas a polynomial of order n can only have n zeroes.

plottaylor[Sin[x],{x,0,6,2},{0,2}]

In fact, for sin(x), it seems like we get better values, and over a wider and wider range, if we just increase the order of the Taylor polynomials.

sint[y_]=Normal[ Series[ Sin[x]/.x->y,{y,0,20}] ];

Plot[ {Sin[x],sint[x]},{x,0,4 Pi},
  PlotStyle->{RGBColor[1.000, 0.069, 0.116],
  RGBColor[0.177, 0.150, 1.000]}]

Example 3
Ln(x), c=1

To approximate ln(x), we must work at c=1, because ln(0) is undefined.  For this function, the approximations do not seem to get better outside of the interval (0,1).  In fact, they get worse!

log5t[y_]=Normal[ Series[ Log[x]/.x->y,{y,1,5}] ];

Plot[ {Log[x],log5t[x]},{x,0.000001,3},
  PlotStyle->{RGBColor[1.000, 0.0, 0],
  RGBColor[0,1,0]}]

log10t[y_]=Normal[ Series[ Log[x]/.x->y,{y,1,10}] ];

Plot[ {Log[x],log5t[x],log10t[x]},{x,0.000001,3},
  PlotStyle->{RGBColor[1.000, 0.0, 0.0],
  RGBColor[0, 1, 0],RGBColor[0, 0, 1],}]

In order to understand what is happening, we must figure out:

  * "The radius of convergence" of the Taylor series - that is, the size r of the interval around c for which the Taylor series converges.   Sometimes this inverval is the whole real line.  But for the logarithm, it seems to be (0,2).
  
  * Whether the Taylor series converges at the endpoints c-r and c+r as well;  for the logarithm, we will see that the series does converge at 2, also.
  
  * Whether the Taylor series, when it converges, actually converges to f(x).  For all the functions we are interested in, this will be true.
  
Our biggest help in this work will be the Ratio test:

  If   limit  | a(n+1)  /  a(n) |    <  1,  then the series converges.