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, including some applications.

Getting Started

To assist you, there is a worksheet associated with this lab that you can copy into your home directory by going to your computer's start menu and choose run. In the run field type:

\\storage\academics\math\calclab

when you hit enter, you can then choose MA1023 and then choose the worksheet

Taylor_start_B14.mw

Remember to immediately save it in your own home directory. Once you've copied and saved the worksheet, read through the background on the internet and the background of the worksheet before starting 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

To use the Taylor and TayPlot commands you need to load the CalcP7 package.
>with(CalcP7);

The exponential function can be approximated at a base point zero with a polynomial of order four using the following command.

>Taylor(exp(x),x=0,4);
You might want to experiment with changing the order. To see $f(x) = \exp(x)$ and its fourth order polynomial use
>TayPlot(exp(x),x=0,{4},x=-4..4);
This plots the exponantial and three approximating polynomials.
>TayPlot(exp(x),x=0,{2,3,4},x=-2..2);
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(exp(x)-Taylor(exp(x),x=0,3)),x=-2..2);
This plot shows that in the domain x from -2 to 2 the error around the base point is zero and the error is its greatest at x = 2 with a difference of over one. 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(exp(x)-Taylor(exp(x),x=0,3))],x=-2..2,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 = 2 whose error is above 0.2. Now try an order of 5. Is the error entirely under 0.2 between x = -2 and x = 2? Larger orders will work as well but order five is the minimum order that will keep the error under 0.2 within the given domain.

Exercises

  1. For the following functions and base points, determine what minimum order is required so that the Taylor polynomial approximates the function to within a tolerance of $0.1$ over the given interval.
    a)
    $f(x) = \exp(x)$, base point $a=0$, interval $[-2,2]$.
    b)
    $\displaystyle f(x) = \ln(1+x)$, base point $a=0$, interval $[-0.9,0.9]$.
    c)
    $\displaystyle f(x) = \frac{\sin(x)}{x^2+1}$, base point $a=0$, interval $[-0.9,0.9]$.

  2. For the function, $f(x) = 1/(3+2x)$, use the TayPlot command to plot the function and multiple Taylor polynomial approximations of various orders 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$.
    a)
    If you increase the order of the Taylor polynomial, can you get a good approximation at $x=2$?
    b)
    Can you make a good guess at the radius of convergence of the Taylor series for $f$ by observing overlap of Taylor polynomials on the plot of $f$?
    c)
    Find the interval of convergence and explain based on what you know about convergence of power series.

  3. You read in the begining of the background that a Taylor Polynomial must have the same y-value, at the base point, as the original function. Also, the derivatives at that point must be the same. Three functions and three second-order polynomials are given; determine which function goes with which Taylor Polynomial by following the steps below.

    \begin{displaymath}
f(x)=e^{(x^5-x)}
\end{displaymath}


    \begin{displaymath}
g(x)=7x+e^x+x^6
\end{displaymath}


    \begin{displaymath}
h(x)=e^{x^5}-e^x+1
\end{displaymath}


    \begin{displaymath}
Taylor1=\frac{x^2}{2}+8x+1
\end{displaymath}


    \begin{displaymath}
Taylor2=\frac{x^2}{2}-x+1
\end{displaymath}


    \begin{displaymath}
Taylor3=\frac{-x^2}{2}-x+1
\end{displaymath}

    a)
    Enter the functions and the polynomials.
    b)
    Find the y-values of all six at $x=0$.
    c)
    Find the first derivative at 0 of all six.
    d)
    Find the second derivative at 0 of all six.
    e)
    Which Taylor Polynomials go with which functions.


next up previous
Next: About this document ... Up: lab_template Previous: lab_template
Dina J. Solitro-Rassias
2014-12-03