Taylor Polynomials

advertisement
Math 175
Worksheet 8: Taylor Polynomials
Introduction:
Basic Idea: (Refer to the text, p. 266)
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
2
3
P3(x)  c0  c1(x  a)  c2 (x  a)  c3(x  a)
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)
3 2c3  f (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
(n)
f (a)  0 . In that case, the nth degree Taylor Polynomial of f centered at x  a would in fact be a
polynomial of degree n 1 or less.
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
For example, suppose f (x)  cos(x) , a  0 and n  3 :
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: 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
2  x 1/ 2
2
f (2)  2
1
4
f (2) 
1
32
f (2)

1

2!
64
3
256
f (2)
3
1


3!
1536 512
1
f (x)   (2  x)3 / 2
4
f (2)
 
3
5/ 2
f (x)  (2  x)
8
f (2) 
The 3rd degree Taylor Polynomial of f at centered at x  2 is therefore
1
1
1
2
3
P3 (x)  2  (x  2)  (x  2) 
(x  2)
4
64
512
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   .
2
Notice that the graphs are identical for approximately 0  x  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.
Problems:
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  cos(2x)
(a) Find P3(x), the 3rd degree Taylor polynomial of f centered at a = 0.
(b) Find Q3(x), the 3rd degree Taylor polynomial of f centered at a = π/2.
(c) Let x = -3: .01: 3; 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 ([-3,3,-5,5]) 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.
3
Problem 2.
In this problem, you will estimate the accuracy of Taylor Polynomials of different degree generated by a
1
x
function. Use f (x)  e 2 . Recall that the Matlab command for eu is exp(u).
(a) Find P2(x), the 2nd degree Taylor polynomial of f centered at a = 0.
 x = -5: .01: 5 and plot f(x) and P2(x) together on the same graph. Use different colors or styles to
(b) Let
distinguish your graphs.
(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). You may want to zoom in.
(d) For x = -5: .01: 5 calculate the maximum value for the error |f(x) – P2(x) | . Use the command:
max(abs(f – p2)). By hand on your graph in part (b), give a visual representation for this maximum error.
(e) Find P3(x), the 3rd degree Taylor polynomial of f centered at a = 0.
(f) Let x = -5: .01: 5 and plot f(x) and P3(x) together on the same graph. Use different colors or styles to
distinguish your graphs.
(g) Use your graph to estimate (to one decimal place) the largest possible interval around
a = 0 in which the graph of P3(x) appears to coincide with the graph of f(x).
(h) For x = -5: .01: 5 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.
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( 4x 1). Recall that the Matlab command for ln(u) is log(u).
In parts (a) and (b), Pn(x) denotes the nth degree Taylor polynomial, centered at a = 0, of f (x)  ln( 4x 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.3 for all x in the array x = -0.2: .01: 0.2.
 - Pn(x) | for x in the array
In your Word document include each Pn(x), and the maximum value of the error |f(x)
x = -0.2: .01: 0.2 from P2 up to your solution.
(b) On a single graph plot f(x) and your Pn(x) for the array x = -0.2: .01: 0.2.

4
Download