Mathematics 36, section 5 -- AP Calculus
Lab Day 3: Taylor Polynomials, Approximations
September 28, 1999
Goals
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.
Background
Recall from class on Monday that if
|f(n+1)(x)| <= M
for all x in [ a - s, a + s] (that
is, all x between a - s and a + s),
then the error in the approximation
of f(x) by pn(x)
(the nth degree Taylor polynomial at a) is bounded as follows
|f(x) - pn(x)| <= (M/(n+1)!) |x-a|n+1
for all x between a - s and a + s.
Taylor Polynomials in Maple
Maple has a ``built-in'' function called taylor that can
be used to compute Taylor polynomials of functions. The general
format is
taylor(f(x),x=a,d);
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:
taylor(exp(x),x=0,6);
Note two things:
1) The output
1 + x + (1/2)x2 +
(1/6)x3 +(1/24)x4+ (1/120)x5 +
O(x6)
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.
To get rid of the error term, you can ``nest'' the taylor
command inside a convert command like this:
convert(taylor(exp(x),x=0,6),polynom);
Try this and note the output.
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.
Lab Questions
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.
- First plot sin(x) and it Taylor polynomial of degree
3 together on the same axes with -3 <= x <= 3. You
can use these commands, for instance, first to compute the
Taylor polynomial, assign it the name p3,
then plot it with the sine function:
p3 := convert(taylor(sin(x),x=0,4),polynom);
plot({sin(x), p3}, x=-3..3);
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.
- Now plot the absolute error function: abs(sin(x)-p3),
together with the function abs(x)^4/24
using the same range of x values: -3 <= x <= 3.
Which graph is which? Also, explain how your graphs
relate to the Theoretical Error Bound for Taylor approximations
to the sine function (see the Background section above).
- Repeat part 2, but replacing the function abs(x)^4/24
with abs(x)^5/120. Use the same range of
x values: -3 <= x <= 3.
Which graph is y = abs(sin(x)-p3) and which is
y = abs(x)^5/120? You should see that
abs(sin(x)-p3) <= abs(x)^5/120 on the whole interval. Why
is this true? (Hint: What is the 4th degree Taylor
polynomial for sin(x) at a = 0?)
- Repeat part 1 for the Taylor polynomial of degree 5 of sin(x)
at a = 0.
- Does using the fifth degree polynomial to
approximate sin(x) seem to yield better
results than using the polynomial of degree 3? For instance,
is the absolute error for this polynomial smaller than the absolute
error for p3 (x) on the whole interval?
- Repeat part 1 for the Taylor polynomials of degree 7, 9, 11 of sin(x)
at a = 0. When you graph the polynomials of degree 9 and 11 together
with the sine function, you may actually only see one graph
on the interval -3 <= x <= 3. What does
that mean? Try plotting a bigger range of x-values until you
see the graphs start to "diverge". When does that happen for the degree
9 polynomial? When for the degree 11 polynomial?
- 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 Theoretical Error Bound above first to
get a rough idea how big n should be. Does a smaller n
than that "work", though?
Lab Writeups Due:
Friday, October 1.