In today's lab will use Maple to compute Taylor polynomial approximations, and use graphical and numerical methods to analyze the error in Taylor approximations.
Recall from class on Tuesday that if f is a function that is n-times differentiable at x = a, then there is a unique polynomial pn of degree <= n whose first n derivatives at x = a are the same as the corresponding derivatives of f at x = a. pn is called the nth degree Taylor polynomial of f at x = a, and can be computed by the formula:
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 the following command which computes the 5th degree Taylor polynomial for f(x) = ex at a = 0:
Note two things:
1) The output
is a polynomial, plus another term. The other term -- O(x6) -- is intended to describe the size of the error. The way to interpret this is that the error will go to zero like (a constant times) x6 (at least) as x -> 0. To get rid of the error term, you can ``nest'' the taylor command inside a convert command like this:
Try this and note the output. You should use this convert step every time you want just the Taylor polynomial, without the error term.
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.
A) In these questions, you will generate plots of sin(x), together with its Taylor polynomials of degrees n = 3,5,7,9,11 at a = 0 and compare the accuracy of the Taylor approximations.
Note: There is no (x) after the p3 in the plotting command; we computed the Taylor polynomial as an expression in the command before, assigned it to the symbolic variable p3 and then used that expression in the plot command.
B) Now, consider the function f(x) = ln(1+x), expanding around a = 0. Plot the Taylor polynomials of degrees 1, 2, 3, 4, 5 and the function on the interval -1 < x < 1. For each degree, find an interval where the Taylor polynomial of that degree approximates f(x) to within 10-3 -- that is: abs(f(x) - pn(x)) < 10-3 for all x in the interval. How do the intervals change as n increases? For instance, does it seem that the interval will grow to arbitrary length as n increases, or is there a "limit" to its size? Explain.
Monday, April 18.