In today's lab will use Maple to compute Taylor polynomial approximations, and use graphical and numerical methods to analyze the error.
Recall from class on Monday and Tuesday that if
Maple has a ``built-in'' function called taylor that can be used to compute Taylor polynomials of functions. The general format is
where f(x) is the function to be approximated, a is the x-value where the Taylor polynomials will be expanded, and d >= 1 is an integer. For example, try entering:
Note two things:
1) The output
is a polynomial, plus another term -- O(x6) -- that describes the size of the error. The way to interpret this is that the error will go to zero like x6 (at least) as x -> 0.
2) The 6 in the Taylor command is one more than the degree of the polynomial. To get the nth degree polynomial, you will always want to take d = n + 1. To get rid of the error term, you can ``nest'' the taylor command inside a convert command like this:
Frequently in larger-scale computations, we want to repeat a computation, say for each value of a number n starting from n=a up to n=b. Maple provides several different mechanisms for repetition of a command. Perhaps the simplest one is the seq (``sequence'') function. If you enter a command
then the command (whatever it is) will be repeated once for each integer value of n between a and b (inclusive), and the output from all will be combined into a single sequence of values. For instance, try entering the following command:
to get the idea. The command inside the seq can be any other Maple command, typically involving the variable n in some way. Here is a more involved, example, which will invoke the taylor command Taylor polynomials for f(x) = ex of degrees 0,1,2,...,10:
(recall the ``shift'' in the taylor function described above; for example taylor(exp(x),x=0,5) computes p4(x)!)
1) In this question, you will generate a plot of sin(x), together with its Taylor polynomials at a=0, of degrees n = 1,3,5,7,9 together on the same axes for -5 <= x <= 5.
a) First generate the set of polynomials with this command:
(Do you see why this works?)
b) Next, to plot the Taylor polynomials together with sin(x) on -5 <= x <= 5, use:
2) Describe in words what happens as the degree of the Taylor polynomial increases. Do the approximations for a given x in [-5,5] get better? Does the interval where the approximation is ``really good'' change? How?
3) Make a table of values (using the error bound for Taylor polynomials as in (1) above) giving the biggest possible error for the Taylor approximations tosin(x) given by pn(x) on [-5,5] for each of the degrees n = 1,3,5,7,9. (All the computations here can be done with the seq command in Maple!) How does your answer in 2) relate to these computations with the error bound?
4) What is the smallest value of n for which the Taylor polynomial of degree n (always with a = 0) approximates sin(x) with 3 decimal digit accuracy for all x between -5 and 5? Use the error bound (1).
Wednesday, October 8.