[Objectives | Exercise | Examples
]
OBJECTIVES
EXERCISE In this problem we will consider the Taylor polynomials centered at a=0 for the function f(x)=sin(x^2/5) for -4 < x < 4. Instructions
Use Taylor's formula to estimated the accuracy En(x) of the approximation
Tn(x)
to f(x) when for -4 < x < 4 and n=4.. To do this problem go through the two examples below. (See especially Example
B below.). In this assignment you will be using
MATLAB's Symbolic Toolbox. To read more about this Toolbox, see Chapter 8 of
Polking and Arnold. Hint: You might (but want to copy the commands used in Example
B into a couple of M-Files. (Click here
to learn how.) Then edit the files to match your problems. Then
run the M-Files to produce the graphs! Example A)
>> hold on % hold on is used so we do not erase the current
figure. To compute the n'th Taylor polynomial you should
use the command
T_n = taylor(f,n+1) if a=0 or T_n = taylor(f,a,n+1)
otherwise.
The command gtext is useful for labeling graphs. When
you type Repeating this process for the Taylor polynomials T5, T7, and T9 will yield the following graph:
The error term, R9(x)=sin(x)-T9(x), is given by
for some z in the interval between 0 and x. Plotting both |R9(x)| and E9(x) can be achieved using the following commands: >> T9=taylor(sin(x),10);The resulting graph is:
Notice that the error estimate E9(x) is above the true remainder |R9(x)| as Taylor's theorem says it should. Just out of curiousity, let's take a look at the degree 29 Taylor polynomial approximation of sin(x). >> T29=taylor(sin(x),30);
In this example we will consider the function f(x)=exp(sin(x)) on the interval -2 < x < 2. Here are the MATLAB commands. To simplify writing we will use the inline command to define f. EDUğ syms x These commands produce the plot like To
use Taylor's theorem to estimate the error between f and T_4 we will need the
5'th derivative of f. This is tedious to compute by hand. Fortunately MATLAB
will do it for us. The command is diff(f(x),n), which computes the
n'th derivative of the function f(x). EDUğ D5=diff(f(x),5)
% This gives a bit of a mess which we now plot on a new graph These commands give the following picture. From
this picture, we see that absolute value of the 5'th derivative of f is bounded
by 25 on the interval of interest. Therefore by Taylor's theorem with remainder,
E(x) < 25|x|^5/5!. To finish off we will graph the absolute value of
R_4(x)=f(x)-T_4(x) and E(x) to verify that |R_4(x)| < E(x) as Taylor's
theorem requires. Here are the commands. EDUğ figure These produce the following plot. Notice
that the graph of E remains above |R_4| as it should. [Objectives | Exercises | Examples
|Extra Problems (Not Required) ]
Extra Problems to Try (Not Required) Instructions 1) f(x)=(1+x)^(-1/2), a=0, n=2, 0 < x < 1/2. 2)
f(x)=ln(x), a=4, n=3, 3 < x < 5. (Hint: type 'help
taylor' to see how to find T_3 in this case.)
|
Jump to Bruce Driver's Homepage. Jump to Current Courses Page.
|