| > |
lab9.mws --- Taylor Polynomials and Their Remainders
| > | restart; with( plots ): with( Student[Calculus1] ): |
Warning, the name changecoords has been redefined
| > |
Auxiliary Procedures (execute, but do not change)
| > | TaylorError := proc(f,center::name={name,numeric},order::name={name,nonnegint}) local a, df, R, x, n; x := lhs(center); a := rhs(center); n := rhs(order); df := simplify(diff( f, x$(n+1) )); R := eval(df,x=c)*(x-a)^(n+1)/(n+1)!; return unapply(R,x) end proc: |
| > |
Lab Overview
The purpose of this lab is to help you develop an understanding of Taylor polynomials. Recall that the Taylor polynomial of order n based at
for a function
is
+ ... +
(
)
In class you have talked about the remainder term for Taylor polynomials. You should have memorized the formula
=
(
)
.
The purpose of this lab is to make some sense out of these definitions. The primary way this will be done is through the use of graphics. The TaylorApproximation command will be used for almost everything that we need in this lab. This command will be used to compute Taylor polynomials and to produce plots (and animations) of Taylor polynomials. For the study of the remainder term, I have created the TaylorError command.
The lab questions are either taken directly from the assigned homework or based on the assigned problems.
Deadline for submitting a lab solution is midnight, Thursday, March 20, 2003.
| > |
Example 1 - # 36 (p. 486)
The Taylor polynomial of order
centered at
for
| > | f1 := 1/(x-3): f(x) = f1; |
is found with theTaylorApproximation command
| > | P[6,1] := TaylorApproximation( f1, x=1, order=6 ); |
Notice that this result is not displayed in terms of powers of (
). This is an unfortunate consequence of the simplifications built into Maple.
| > |
To see how this polynomial is related to the original function on an interval, say [ -3, 3 ], use the above command with the plotting interval specified as -3..3 and the argument output=plot added to the previous command:
| > | TaylorApproximation( f1, x=1, order=6, -3..3, output=plot ); |
| > |
Notice how
does an excellent job of approximating the original function at and near
and the approximation becomes worse and worse the further
moves from
.
In this exercise you are asked to look at the remainder term
| > | R[6] := TaylorError( f1, x=1, order=6 ); |
where c is a number between
and
. For
this simplifies to
| > | R[6](0.5); |
where 0.5 <
< 1. To determine the largest possible value of this remainder term, plot the (absolute value of the) remainder -- as a function of
-- over the interval of possible values for
:
| > | plot( abs(R[6](0.5)), c=0.5..1 ); |
Two observations are immediately obvious from this:
i) the remainder are small for all values of
ii) the largest possible value of this remainder occurs when
| > | MaxError := eval( abs(R[6](0.5)), c=1 ); |
What this means is that
<= 0.000031
To verify this result, compute the "actual" error between the function and its Taylor polynomial at
= 0.5
| > | ActualError := eval( abs(f1-P[6,1]), x=0.5 ); |
and note that this error is within the error bound that we found.
| > | evalb( ActualError < MaxError ); |
| > |
Example 2 - Estimating
This example presents the ideas needed to answer Lab Question 2 (#39, p. 486 of the text).
The Maclaurin polynomials for
| > | f2 := exp(x): f(x) = f2; |
of all orders up to
| > | N := 5; |
are
| > | for n from 0 to N do P[n,0] := TaylorApproximation( f2, x=0, order=n ); end do; |
Recall that the coefficient of x^n is
=
.
The numerical estimates these provide for an approximation to
= exp(1) are
| > | for n from 0 to N do eval( P[n,0], x=1. ); end do; |
To know how accurate these approximations are, the corresponding remainder terms are needed:
| > | for n from 0 to N do R[n] := TaylorError( f2, x=0, order=n ); end do; |
where each
is a number between 0 and 1.
Now, since we are trying to estimate a numerical value of
, it is not fair to use values of
in these estimates. It is known that 2 <
< 3. This, combined with our knowledge that 0 <
< 1 allow us to conclude that
<
< 3. Using this, we obtain the following bounds when the Maclaurin polynomials are evaluated at
:
| > | for n from 0 to N do RR[n] := subs( exp(c)=3, R[n](1.) ); end do; |
What this tells, in particular, is that the Maclaurin polynomial of order 4 can be used to estimate
to one decimal place and the Maclaurin polynomial of order 5 provides an estimate that is accurate to 2 decimal digits.
To answer Lab Question 2 you need to determine the value of n that provides an estimate that is accurate to 5 decimal digits.
| > |
It is interesting to watch the Maclauring polynomials converge to the exponential function. The simplest way to obtain an animation of this is
| > | TaylorApproximation( f2, x=0, order=0..10, -5..5, output=animation ); |
Notice how the higher-order Maclaurin polynomials provide a reasonable approximation to the exponential function on a larger interval (centered at
).
| > |
Example 3 - # 42
This problem asks us to bound the error R[4](x) for -0.5 <= x <= 0.5 for the fourth-order Maclaurin polynomial for
| > | f3 := ln( (1+x)/(1-x) ): f(x) = f3; |
| > |
| > | P[4,0] := TaylorApproximation( f3, x=0, order=4 ); |
| > |
Our first view of the error that we are attempting to plot is seen in a plot of the y=f(x) and y=T[3,0](x):
| > | TaylorApproximation( f3, x=0, order=4, -0.5..0.5, output=plot ); |
From this it appears that T[3,0](x) is a very good approximation to f(x) on [ -0.5, 0.5 ]. A second view of the error is seen in the following plot of the difference between the function and the Taylor polynomial:
| > | plot( f3-P[3,0], x=-0.5..0.5 ); |
From this it appears as though the largest errors occur at the endpoints of the interval: x = -0.5 and x = 0.5. The precise formula for R[4](x) is
| > | R[4] := simplify(TaylorError( f3, x=0, order=4 )); |
In particular, when x = -0.5 and x = 0.5, the error bounds are
| > | r1 := R[4](-0.5); r2 := R[4]( 0.5); |
| > | p1 := plot( r1, c=-0.5..0 , color=red, legend=["R[4](-0.5)"] ): p2 := plot( r2, c= 0 ..0.5, color=blue, legend=["R[4]( 0.5)"] ): display( [p1,p2] ); |
The largest errors obviously occur at the endpoints:
| > | r3 := eval( r1, c=-0.5 ); r4 := eval( r2, c= 0.5 ); |
This means
-0.2008 <=
=
<= 0.2008
or
=
<= 0.2008. for all -0.5 <=
<= 0.5.
Thus, an error bound for the fourth-order Maclaurin polynomial for
on -0.5 <=
<= 0.5 is
<= 0.2008. for all -0.5 <=
<= 0.5.
| > |
Example 4 - Application of # 42
The result in Example 3 can be very useful. For example if you want compute the definite integral
| > | q1 := Int( f3, x=0..1/2 ): q1; |
There are several options. First, the definite integral could be evaluated exactly. An antiderivative can be found by rewriting ln((1+x)/(1-x)) as ln(1+x) - ln(1-x) and then integration by parts to evaluate each integral. This is a long - and difficult - set of operations. An alternate method for approximating the integral is to replace the integrand with a Taylor (Maclaurin) polynomial with remainder term:
so that
<=
To conclude, note that
| > | q2 := Int( P[4,0], x=0..1/2 ): q2 = value(q2); ` ` = evalf(q2); |
and the error in this result is no more than 0.1004.
Maple will perform the exact integration without complaint. The result of this calculation is
| > | q1 = value(q1); ` ` = evalf(q1); |
From this calculation it is seen that the actual error is much smaller than 0.1004, but the results are consistent.
| > |
Lab Questions
1. Modify Example 1 to provide a good estimte for
for
with
. (This is #33 in the text.)
2. Modify Example 2 to answer the question posed in #39.
Bonus (2 pts): How many terms are needed to estimate
to 15 decimal digits? What is this estimate?
Hint: You will need execute the command such as Digits := 25: to get Maple to work with more than 10 decimal places.
3. #41.
4. #43
5. #45
6. [Essay Question] (2 pts) Let f be a polynomial of degree
. Explain why
for all
and for all
.
| > |
| > |
| > |