MATH1020 Calculus II Maple Lab 7
Section 1-4 Due: Tuesday, November 9, 1999.
http://www.math.rpi.edu/~mitchj/math1020  

In this lab, we examine a power series and a Taylor approximation. Be sure to follow the lab guidelines as described on the class handouts.

1.
A power series is a series of the form

\begin{displaymath}
c_0+c_1(x-a)+c_2(x-a)^2+\cdots = \sum_{n=0}\sp\infty c_n(x-a)^n.
\end{displaymath}

In this series, {cn} and a are constants and x is variable. Clearly the value of the sum changes for different values of x (assuming the series converges), and thus it can be considered as a function, that is

\begin{displaymath}
f(x) = \sum_{n=0}\sp\infty c_n(x-a)\sp n.
\end{displaymath}

Let us consider a specific power series and examine its behavior. Let

\begin{displaymath}
f(x) = \sum_{n=0}^\infty{(-1)\sp n\over(2n)!}\left(x-{\pi\over2}
\right)^{2n}.
\end{displaymath}

(a)
To get a handle on whether this power series converges for values of x different than $a=\pi/2$, consider the series when $x=\pi$ and show that the series converges absolutely for that value of x using the ratio test, either by hand or using Maple. (In fact, it can be shown that the series converges for all finite values of x.)

(b)
The next question is what does the series converge to? In other words, what does f(x) look like? To investigate this, let's examine the partial sums as functions of x. Type

> Sn:=n->sum(((-1)**k)*((x-Pi/2)**(2*k))/(2*k)!,k=0..n);
> plot({Sn(1),Sn(3),Sn(6),Sn(9)},x=-2*Pi..4*Pi,-1..1);

As the number of terms in the partial sums gets larger and larger, the sums approach f(x). The function f is a standard function. Can you guess what it is?

2.
Recall that the $n\sp{{\rm th}}$ degree Taylor polynomial approximation of a given function f(x) about a point x=c is given by the formula

\begin{displaymath}T_n(x)=f(c)+f^\prime(c)(x-c)+{f^{\prime\prime}(c)\over2!}(x-c)^2+\ldots
+{f^{(n)}(c)\over n!}(x-c)^n\end{displaymath}

In order to generate a Taylor polynomial approximation of f, we will use the Maple commands ``taylor'' and ``convert'' as indicated below.

Let $f(x)=e^x+\sin(x)$ and consider the interval $-6\le x\le2$. To generate the Taylor polynomial of degree two about c=-2 and plot it together with f, type

> f:=exp(x)+sin(x);
> T2:=convert(taylor(f,x=-2,3),polynom);
> plot({f,T2},x=-6..2);

The 3 in the argument of the taylor command gives the order of the Taylor approximation including the error which is the degree of the polynomial plus one. The convert command chops off the error term.

(a)
Obtain the second, fourth, sixth, and eighth degree Taylor polynomial approximations of f about c=-2 and compare each to the function f. How do the approximations behave as the degree of the polynomial increases?

(b)
Let us now consider the error in the approximation at the ends of the interval as the degree of the polynomial increases. To obtain these values and plot them, type

> for n from 0 to 10 do
> Tn:=convert(taylor(f,x=-2,n+1),polynom);
> Eleft[n]:=evalf(subs(x=-6,abs(Tn-f)));
> Eright[n]:=evalf(subs(x=2,abs(Tn-f)));
> od:

(The colon at the end of od suppresses a lot of unnecessary output.)

> L:=[[j,Eleft[j]] $j=0..10]: plot(L);
> R:=[[j,Eright[j]] $j=0..10]: plot(R);

Discuss the plots of the error. Is the behavior consistent with what you would expect? Does the error decrease monotonically? Should it?

(c)
Normally the point c is taken to be some convenient value and then the degree of the polynomial approximation is chosen to obtain a desired accuracy. Conversely, we might also consider fixing the degree of the polynomial and then varying the point c to obtain the best'' approximation. Let us agree that best means the value of c that minimizes the integrated error

\begin{displaymath}\int_{-6}^2(T_n(x)-f(x))^2\,dx\end{displaymath}

for a given degree n. For n=4, define this error in Maple using the command

> Error:=int((convert(taylor(f,x=c,5),polynom)-f)**2,x=-6..2);

The result of this command is a bit of a mess but we will let Maple worry about that. The important thing is that Error is a function of c. Plot this error using

> plot(Error,c=-6..2);

Notice that this curve has several local minima and maxima. Use the usual procedure for finding the minimum of a function to find the best value for c. Plot the corresponding Taylor approximation and f(x) on the same graph.



 
John E Mitchell
1999-10-22