Next: New Series from Up: Labs and Projects for Previous: Quadratic Taylor Polynomial

# Taylor Polynomials

## Purpose

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

## Background

In the previous lab, we introduced quadratic Taylor polynomial approximations. In this lab, we investigate higher-order Taylor polynomials.

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

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

The general form of the Taylor polynomial approximation of order n to is given by the following

We will be seeing this formula a lot, so it would be good for you to start memorizing it now! The notation is used in the definition to stand for the value of the k-th derivative of f at x=a. That is, , , and so on. By convention, . Note that a is fixed and so the derivatives are just numbers. The following easier theorem should help you to see where the formula comes from.

Maple has a command called taylor to generate these Taylor polynomial expansions, but the form it produces is not the most convenient, so two commands have been written as part of the CalcP package, which should be loaded with the following command.

```  > with(CalcP):
```

The two procedures are called Taylor and TayPlot. The syntax for Taylor is
Taylor(f,x=a, n);,
where n is the order, f is an expression or a procedure, and a is the base point. The following examples should make the use of this procedure clear. There is also help available with the command ?Taylor.

```  > Taylor(sin(x),x=0,3);
```

```  > Taylor(sin(x),x=0,15);
```

```  > Taylor(sin(x),x=Pi/6,4);
```

```  > Taylor(exp(x),x=0,5);
```

The result of this command is a polynomial expression that can be plotted, differentiated, etc.

It seems intuitive that the larger n is, the better the Taylor polynomial will approximate . To help you investigate this, a procedure TayPlot has been written which plots and a set of Taylor polynomials simultaneously. The syntax for this command is
TayPlot(f,x=a,{n1,n2,n3, ...},x=b..d,ops);,
where f and x=a are as above, x=b..d is the usual x plot range specifier, and ops are (optional) options that TayPlot passes to the plot command. The set {n1,n2,n3, ...} consists of integers corresponding to the Taylor polynomial degrees desired. For example,

```  > TayPlot(sin(x),x=0,2,3,5,x=-Pi..Pi);
```

```  > TayPlot(sin(x),x=0,2,3,5,x=-Pi..Pi,y=-1.2..1.2);
```

are both valid calls of TayPlot. Both plot and the 2nd, 3rd, and 5th order Taylor polynomial approximations. In the second TayPlot command, the y range has been set to fit the behavior of the function. You can plot more than three Taylor polynomials if you want, of course. You can also use a letter other than x for your independent variable. Help for TayPlot is available with the ?TayPlot command.

## Examples

1. , a=0, order 1, order 2, order 3.
2. , a=0, , order 4, order 5, order 6.
3. , a=0, order 8, order 13, order 21.

## Accuracy and Tolerance

To measure how well a Taylor Polynomial approximates the function over a specified interval , we define the tolerance Tol of to be the maximum of

over the interval . You can actually see how the error of a Taylor polynomial varies over an interval with a Maple command like

```  > plot(abs(sin(x)-Taylor(sin(x),x=0,3)),x=-1..1);
```

For this example, the tolerance, Tol, is about , which you can find out by looking at the graph.

Now suppose you were asked to determine the order required so that the Taylor polynomial approximation to had a tolerance of on the interval . One simple method for doing this graphically is shown below.

```  > plot(abs(sin(x)-Taylor(sin(x),x=0,3)),x=-1..1,y=0..0.005);
```

If you look at the plot, you see that the curve goes out of the plot on the top of the window. This means that the tolerance is not satisfied. If the order is increased to 5, as in the following example, then the curve goes out of the plot on the sides, meaning that the tolerance is satisfied.

```  > plot(abs(sin(x)-Taylor(sin(x),x=0,5)),x=-1..1,y=0..0.005);
```

## Exercises

1. For the following functions and base points, determine what order is required so that the Taylor polynomial approximates the function to within a tolerance of over the given interval. Include explnations how you got your answers in your report.
1. , a=0, interval .
2. , a=0, interval .
3. , a=0, interval .
4. , a=1, interval .

2. Prove Theorem . Remember that an example is not a proof!

3. For the third function in exercise 1, , consider the Taylor polynomial about a=0. Can you choose the order so that the Taylor polynomial is a good approximation (within , say) to at x=2? How about at ? Discuss the difference in the behavior of the Taylor polynomials at these two points. Can you divide the real line up into two parts, one where the approximation is good and one where it is bad?

Next: New Series from Up: Labs and Projects for Previous: Quadratic Taylor Polynomial

William W. Farr
Tue Jun 27 15:37:50 EDT 1995