next up previous
Next: About this document ... Up: lab_template Previous: lab_template

Subsections


Taylor Polynomials

Purpose

The purpose of this lab is to use Maple to introduce you to Taylor polynomial approximations to functions and Taylor series.

Getting Started

To assist you, there is a worksheet associated with this lab that contains examples similar to some of the exercises. On your Maple screen go to F ile - Open then type the following in the white rectangle:
\\storage\academics\math\calclab\MA1023\Taylor_start_C18.mw
You can copy the worksheet now, but you should read through the lab before you load it into Maple. Once you have read through the exercises, start u p Maple, load the worksheet, and go through it carefully. Then you can start wor king on the exercises.

Background

The idea of the Taylor polynomial approximation of order $n$ at $x=a$, written $P_n(x,a)$, to a smooth function $f(x)$ is to require that $f(x)$ and $P_n(x,a)$ have the same value at $x=a$. Furthermore, their derivatives at $x=a$ must match up to order $n$. For example the Taylor polynomial of order three for $\sin(x)$ at $x=0$ would have to satisfy the conditions

\begin{displaymath}\begin{array}{ccccc}
P_3(0,0) & = & \sin(0) & = & 0\\
P_3'...
... & = & 0 \\
P_3'''(0,0) & = & -\cos(0) & = & -1
\end{array}\end{displaymath}

You should check for yourself that the cubic polynomial satisfying these four conditions is

\begin{displaymath}P_3(x,0) = x - \frac{1}{6} x^3.\end{displaymath}

The general form of the Taylor polynomial approximation of order $n$ to $f(x)$ is given by the following

Theorem 1   Suppose that $f(x)$ is a smooth function in some open interval containing $x=a$. Then the $n$th degree Taylor polynomial of the function $f(x)$ at the point $x=a$ is given by


\begin{displaymath}P_n(x,a) = \sum_{k=0}^{n} \frac{f^{(k)}(a)}{k!} (x-a)^k \end{displaymath}


\begin{displaymath}= f(a) + f'(a)(x-a) + \frac{f''(a)}{2}(x-a)^2 + \cdots
+ \frac{f^{(n)}(a)}{n!} (x-a)^n\end{displaymath}

We will be seeing this formula a lot, so it would be good for you to memorize it now! The notation $f^{(k)}(a)$ is used in the definition to stand for the value of the $k$-th derivative of $f$ at $x=a$. That is, $f^{(1)}(a) = f'(a)$, $f^{(3)}(a) = f'''(a)$, and so on. By convention, $f^{(0)}(a) =
f(a)$. Note that $a$ is fixed and so the derivatives $f^{(k)}(a)$ are just numbers. That is, a Taylor polynomial has the form

\begin{displaymath}\sum_{k=0}^{n} a_k (x-a)^k \end{displaymath}

which you should recognize as a power series that has been truncated.

Accuracy and Tolerance

To measure how well a Taylor Polynomial approximates the function over a specified interval $[c,d]$, we define the tolerance $Tol$ of $P_n(x,a)$ to be the maximum of the absolute error

\begin{displaymath}\mid f(x)- P_n(x,a) \mid \end{displaymath}

over the interval $[c,d]$.

Maple Commands

The exponential function can be approximated at a base point zero with a polynomial of order four using the following commands.
>taylor(exp(x),x=0,4);
>mtaylor(exp(x),x=0,4);
The second command truncates the order term and this is the one that is used in this lab. You might want to experiment with changing the order. Below is an example of $\displaystyle f(x) = \ln(x+1)$ and four approximating polynomials. Note, only the first command has a semi-colon whereas the output is suppressed for the higher order polynomials.
>f:=x->exp(x)
>tp1:=mtaylor(f(x),x=0,10);
>tp2:=mtaylor(f(x),x=0,25):
>tp3:=mtaylor(f(x),x=0,50):
>tp4:=mtaylor(f(x),x=0,100):
This plots the function and four approximating polynomials.
>plot({f(x),tp1,tp2,tp3,tp4},x=-3..3,y=-5..5);
Notice that the further away from the base point, the further the polynomial diverges from the function. The amount the polynomial diverges i.e. its error, is simply the difference of the function and the polynomial.
>plot(abs(ln(x+1)-mtaylor(ln(x+1),x=0,3)),x=-0.9..0.9);
This plot shows that in the domain x from -0.9 to 0.9 the error around the base point is zero and the error is its greatest near the endpoints of the interval. You can experiment with the polynomial orders to change the accuracy. If your work requires an error of no more than 0.2 within a given distance of the base point then you can plot your accuracy line y = 0.2 along with the difference of the function and the Taylor approximation polynomial.
>plot([0.2,abs(ln(x+1)-mtaylor(ln(x+1),x=0,3))],x=-0.9..0.9,y=0..0.25);
We knew this would have some of its error well above 0.2. Change the order from three to four. As you can see there are still some values in the domain close to x = -0.9 whose error is above 0.2. Now try an order of 11. Is the error entirely under 0.2 between x = -0.9 and x = 0.9? Larger orders will work as well but eleven is the minimum order required to keep the error under 0.2 within the given domain.

Exercises

  1. a)
    Plot the function, $f(x) = \ln(x+1)$, and four approximating Taylor polynomials with base point $a=0$ on the same graph over the interval $-3 \leq x \leq 3$; use a y-range from $-5$ to $5$. Can you make a good guess at the interval or radius of convergence of the Taylor series for $f$?

    b)
    Define a sequence $a(n)$ that mimics the terms of the series. Use the command below to check that you have the correct sequence.
    seq(a(n),n=1..10);
    
    Use the Ratio Test on these terms to find the interval or radius of convergence.

    c)
    Find the minimum order required so that the Taylor polynomial approximates $f(x)$ with error no greater than $0.1$ over the interval $[-0.9,0.9]$.

  2. Repeat all of exercise 1 using $f(x)=\displaystyle \frac{1}{2+3x}$ using the same domain and range for the plot in part a, but interval $[-0.6,0.6]$ for part c.

  3. Repeat all of exercise 1 using $f(x)=\displaystyle \frac{1}{x^2+4}$ using the same domain and range for the plot in part a, but interval $[-1.98,1.98]$ for part c.

  4. A theorem from complex variables says that the radius of convergence of the Taylor series of a function $f$ is the distance between the base point ($a=0$ in this case) and the nearest singularity of the function. By singularity, what is meant is a value of $x$ where the function is undefined. Determine the singularity for each function above and the distance between the singularity and the base point for each of the previous exercises. Is this consistent with the radius of convergence that you found?


next up previous
Next: About this document ... Up: lab_template Previous: lab_template
Dina J. Solitro-Rassias
2018-02-08