Professional Documents
Culture Documents
CHAP 04e
CHAP 04e
Chapter 4
1
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
How does a CPU compute the following functions for a specific x value?
cos(x) sin(x) ex log(x) etc.
• Taylor series provides a means to predict the value of a function at one point in
terms of the function value and its derivatives at another point.
2
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Taylor Series (nth order approximation):
f ' ( xi ) f " ( xi ) 2 f ( n ) ( xi )
f ( xi 1 ) f ( xi ) ( xi 1 xi ) ( xi 1 xi ) ( xi 1 xi ) n Rn
1! 2! n!
The Reminder term, Rn, accounts for all terms from (n+1) to infinity.
f ( n 1) ( ) ( n 1)
Rn h
(n 1)!
3
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Any smooth function can be approximated as a polynomial.
Take x = xi+1 Then f(x) ≈ f(xi) zero order approximation
f ( x) f ( xi ) f ' (first
xi )( xorder
xi )approximation
Second order approximation:
f ' ( xi ) f " ( xi )
f ( x) f ( xi ) ( x xi ) ( x xi ) 2
1! 2!
nth order approximation:
f ' ( xi ) f " ( xi ) 2 f ( n ) ( xi )
f ( x) f ( xi ) ( x xi ) ( x xi ) ( x xi ) n Rn
1! 2! n!
• Each additional term will contribute some improvement to the approximation. Only
if an infinite number of terms are added will the series yield an exact result.
• In most cases, only a few terms will result in an approximation that is close enough
to the true value for practical purposes
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example
Approximate the function f(x) = 1.2 - 0.25x - 0.5x2 - 0.15x3 - 0.1x4
from xi = 0 with h = 1 and predict f(x) at xi+1 = 1.
5
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example:
computing f(x) = ex using Taylor Series expansion
f ' ( xi ) f " ( xi ) 2 f ( n ) ( xi )
f ( xi 1 ) f ( xi ) ( xi 1 xi ) ( xi 1 xi ) ( xi 1 xi ) n Rn
1! 2! n!
As a result we get:
2 3 n
x x x x Looks familiar?
2 4 6
x x x
cos x 1
2! 4! 6!
7
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Notes on Taylor expansion:
8
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
**here Error Propagation
• Let xfl refer to the floating point representation of the real number x.
• Since computer has fixed word length, there is a difference between x and xfl
(round-off error)
and we would like to estimate the error in the calculation of f(x) :
f ( x fl ) f ( x) f ( x fl )
• Both x and f(x) are unknown.
• If xfl is close to x, then we can use first order Taylor expansion and compute:
f ( x) f ( x fl ) f ( x fl )( x x fl )
f ( x fl ) f ( x fl ) * x
Result: If f’(xfl) and Dx are known, then we can estimate the error using this formula