Taylor Polynomials

advertisement
Math 175
Worksheet 8: Taylor Polynomials
Introduction:
Basic Idea: (Refer to the text, p. 269)
Let f be a function defined on some domain containing the point x  a . Sometimes we can represent a
more complicated function in terms of a polynomial function. This can be very helpful as polynomial functions
can be easily examined. Suppose we want to use a polynomial of a certain fixed degree to approximate the
function f as well as we can in some neighborhood of the point of interest x  a . For clarity we will assume
that we have a polynomial of degree 3. We can write a general polynomial of degree 3 as
P3(x)  c0  c1(x  a)  c2 (x  a)2  c3(x  a)3
where c0 ,c1 ,c 2 ,c3 are arbitrary constants. (It is more convenient to express the polynomial in powers of (x  a)
rather than in powers of x .)
How do we specify these constants to "best" approximate our function f in the vicinity of the point x  a ?
What do we mean by 'best'?
We'll answer both questions in the following way.
We would certainly want the polynomial P3 and the function f to have the same value at x  a . Setting
P3 (a)  f (a) leads to
c0  f (a) .
This determines the first coefficient.
Next, it seems reasonable to require that the polynomial and function have the same slope at x  a . We
guarantee that the two functions will have the same slope by setting their derivatives equal to each other.
Since P3(x)  c1  2c2 (x  a)  3c3(x  a)2 , setting P3(a)  f (a) leads to
c1  f (a) .
Continuing along in this manner, we next require that the polynomial and function have the same second
derivative at x  a . Since P3''(x)  2c2  3 2c3 (x  a) , setting P3''(a)  f ''(a) leads to
2c2  f (a)
 ,
f (a)

or c2 
.
2
By now, the pattern is hopefully apparent. To specify the last coefficient c3 , we equate the third derivatives of
(3)
(3)
P3 and f at x  a . Setting P (a)  f (a) leads to
3 2c3  f (3) (a) ,
f (3) (a)
or c3 
.
3 2
Our desired polynomial is therefore
P3 (x)  f (a)  f (a)(x  a) 
f (a)
f (3) (a)
(x  a)2 
(x  a) 3 .
2
3 2
This is the Third Degree Taylor Polynomial of f centered at x  a . (If we had a polynomial of higher
degree, we would continue to equate higher derivatives of the polynomial and function, evaluated at the point of
interest.)
1
We have written the above denominator as 3 2 (or 3 2 1) rather than simply 6 to emphasize the general
pattern.
Recall factorial notation. 3! 3 2 1, 4! 4  3 2 1, ..., n! n(n 1)(n  2)  21 .
Using this factorial notation, we can represent the nth degree Taylor Polynomial of f centered at x  a as:
Pn (x)  f (a)  f (a)(x  a) 
f (a)

f (3) (a)
f (n) (a)
(x  a) 2 
(x  a)3   
(x  a)n
2!
3!
n!
Remark: For a particular choice of function f , point of interest x  a , and integer n , it may be the case that
f (n) (a)  0 . In that case, the n th degree Taylor Polynomial of f centered at x  a would in fact be a
polynomial of degree n 1 or less.


Example 1: suppose f (x)  cos(x) , a  0 and n  3 :
f (x)  cos x
f (0)  1
f (x)  sin x
f (0)  0
f (x)
   cos x
f (0)  1
f (x)
  sin x
f (0)  0
f (0)
f (3) (0)
1
0
1
2
P3 (x)  f (0)  f (0)(x  0) 
(x  0) 
(x  0)3  1 (0)(x)  (x)2  (x) 3  1 x 2
2!
3!
2
6
2
This is a polynomial of degree 2. And, in fact, P2 (x)  P3 (x) for this example.
Example 2: Consider the function f (x)  2  x . Suppose we want to compute the 3rd degree Taylor
Polynomial of f centered at x  2 . Then, we must compute
f (x)  2  x
f (x) 
1
1/ 2
2  x 
2
f (2)  2
f (2) 
1
f (x)   (2  x)3 / 2
4
f (2)  
3
f (x)  (2  x)5 / 2
8
f (2) 
1
4
1
32
3
256
2
The 3rd degree Taylor Polynomial of f at centered at x  2 is therefore:
f (a)
f (a)
(x  a) 2 
(x  a) 3
2!
3!
 1 
3
 
 32 

(x  2) 2  256 (x  2) 3
2 1
3 2 1
1
1

(x  2) 2 
(x  2) 3
64
512
P3 (x)  f (a)  f (a)(x  a) 
1
(x  2)
4
1
P3 (x)  2  (x  2)
4
P3 (x)  2 
The following graph shows both f (x)  2  x and P3 (x) on the interval 4  x  10 . Note that the natural
domain of f (x)  2  x is 2  x   while the natural domain of P3 (x) is   x   .
Notice that the graphs are identical for approximately 0  x  4 . We say the interval of convergence for
f (x) and P3 (x) is [0, 4].
4

3.5
3
2.5
2
1.5
1
0.5
0
-0.5
-4
-2
0
2
4
6
8
10
The problems assigned in this worksheet will ask you to construct and study Taylor Polynomials for a variety of
functions f and points of interest x  a .
Instructions:
 Number each problem clearly and circle answers.
 You should generate all Taylor Polynomials by hand. Then use Matlab to create graphs and make any error
calculations.
 Be sure you write the Taylor Polynomials you generated on your Word document.
 Do NOT use the Symbolic Toolbox for these problems.
 Between problems remember to use the commands: zoom off and hold off.
 You may use “format short” for this worksheet.
 In some of the following exercises you may find the command "max(y)" helpful. The command returns the
maximum value in the array y.
3
Problem 1.
In this problem, you will compare the effects of using Taylor polynomials of the same degree generated by the
same function, but at different values for a. Use f (x)  2x  cos2x
(a) Find P3 (x) , the third degree Taylor polynomial of f centered at a  0 .
(b) Find Q3 (x) , the third degree Taylor
polynomial of f centered at a 

2
.

(c) Let x = -2: .01: 4;

On a single graph, plot f (x) as a solid line, P3 (x) as a dashed line, and Q3 (x) as a dotted line.

Use the Matlab command axis ([-2,4,-4,6]) to set the horizontal
 and vertical axes.
(Recall a dashed line is '-- ' and a dotted line is ' : ')
(d) From your graphs, which of the Taylor polynomials gives the better approximation of f (x) at x = 0.1?



Explain why.
Which of the Taylor polynomials gives the better approximation of f (x) at x = 1.8? Explain why.


Problem 2.
In this problem, you will estimate the accuracy of Taylor Polynomials of different degree generated by a
function. Use f (x)  e 2x . Recall that the Matlab command for e u is exp(u).
(a) Find P2 (x) , the second degree Taylor polynomial of f (x) centered at a = 0.


(b) Let x = -1: .01: 1 and plot f (x) and P2 (x) together on the same graph.
(c) Use your graph to estimate (to one decimalplace) the largest possible interval around a = 0 in which the
graph of P2 (x) appears to coincide with the graph of f (x) .


That is: Find the interval
of convergence
of P2 (x) and f (x) . You will want to zoom in.
(d) For x = -1: .01: 1 calculate the maximum value for the error f (x)  P2 (x) .


Use the command: max(abs(f – p2)).
 representation for this maximum error.
By hand on your graph in part (b), 
give a visual
(e) Find P3 (x) the third degree Taylor polynomial of f(x) centered at a = 0.
(f) Let x = -1: .01: 1 and plot f (x) and P3 (x) together on the same graph
(g) Use your graph to find the interval of convergence

of P3 (x) and f (x) (to one decimal place) around a = 0.
(h) For x = -1: .01: 
1 calculatethe maximum value for the error f (x)  P3 (x) .
By hand on your graph in part (f), give a visual representation for this maximum error.



4
Problem 3.
In this problem, you will determine the order of the Taylor polynomial you need to use in order to achieve a
desired accuracy. Use f (x)  ln( 3x 1) . Recall that the Matlab command for ln(u) is log(u).
In parts (a) and (b), Pn (x) denotes the n th degree Taylor polynomial, centered at a = 0, of f (x)  ln( 3x 1) .
 with Taylor polynomials of various degrees until you find the smallest integer n so that the
(a) Experiment
maximum error, f (x)  Pn (x), is less than 0.2 for all x in the array x = -0.25: .01: 0.25.
 document include each P (x) and the maximum value of the error f (x)
  P (x) for x in the array
In your Word
n
n
x = -0.25: .01: 0.25 from P2 up to your solution.

(b) On a single graph plot f (x) and your Pn (x) for the array x = -0.25: .01: 0.25.





5
Download