Next: Exercises Up: Taylor Polynomials Previous: Accuracy and Tolerance

## 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 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.

Next: Exercises Up: Taylor Polynomials Previous: Accuracy and Tolerance
William W. Farr
2006-04-03