Professional Documents
Culture Documents
CH 04
CH 04
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?
•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’s theorem: If a function f and its (n+1) derivatives are
continuous on an interval containing x and x0, then the value of the
function at x is given by,
f ( x) Pn ( x) Rn ( x)
f ' ( x0 ) f " ( x0 ) f ( n) ( x0 )
Pn ( x) f ( x0 ) ( x x0 ) ( x x0 )
2
( x x0 ) n
1! 2! n!
3
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
f ( n1) ( ) : a value of x that lies
Rn ( x) ( x x0 ) ( n1)
(n 1)! somewhere between x0 and x.
4
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Any smooth function can be approximated as a polynomial.
nth order Taylor series expansion will be exact for an nth order polynomial
6
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 4.2
Use Taylor series expansion with n=0 to 6 to approximate f(x) = cos x
at x= /3 on the basis of the value of f(x) and its derivatives at x0= /4.
In this course, all angles are assumed to be in radian unless you are told otherwise.
This inequality is used to bound the error terms associated with Taylor
polynomials and hence, have an analytic bound on the error of approximation.
M n1
Rn ( x) x x0
(n 1)!
where
M max f ( n 1) ( ) : x0 x
9
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 4.3
a)Determine 2nd Taylor polynomial for the function f(x) about x0=0.
x
f ( x) e cos( x)
b) Use this polynomial to approximate f(0.5)
c) Use Taylor inequality to find the error bound for the truncation
error and find an interval for the actual function value.
Note: x is in radians.
Answer: a) f ( x) 1 x
b) f (0.5) 1.5
c) R2 (0.5) 0.0932
1.4068 f (0.5) 1.5932
Actual value : f (0.5) 1.4469
10
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 4.4
f ( ~
x ) f ( x) f ( ~
x) an estimate of the error of the function
12
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
If ~
x is close to x and f(x) is continuous and differentiable, Taylor series expansion
of f(x) around ~ x
f ( ~
x )( x ~
x )2
f ( x) f ( ~
x ) f ( ~
x )( x ~
x)
2!
f ( x) f ( ~
x) f ( ~
x )( x ~
x ) 1st order estimate
f ( ~
x ) f ( x) f ( ~
x ) f ( ~
x ) ~
x
13
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 4.5
x ~ 0.01
Given a value of ~ x 2.5 with an error of
estimate the resulting error in the function f ( x ) x
3
Answer:
f ( ~
x ) 0.1875
f (~x ) 15.625
f ( x) 15.625 0.1875
14
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Functions of more than one variable
For n independent variables ~
x1, ~
x2 , ~
xn having errors
~
x1, ~
x2 ,~
xn
~ ~ ~ f ~ f ~ f ~
f ( x1, x2 xn ) x1 x2 xn
x1 x2 xn
15
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
16
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 4.6
v(t )
gm
c
1 e( c / m )t
Use a first-order error analysis to estimate the error of velocity at
t=6s, if g=9.8 m/s2 and m=50±2 kg and c=12.5 ±1.5 kg/s.
Answer:
v(c~, m
~ ) 0.2733
v~ 30.4533
v 30.4533 0.2733
17
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Stability and Condition
•The condition of a mathematical problem-relates to its sensitivity to
changes in its input values.
•A computation is numerically unstable if the uncertainty of the input
values is grossly magnified by the numerical method.
Condition number provides a measure for how an uncertainty in x affects f(x)
f ( ~
x )( x ~
x)
The relative error of f(x):
f (~x)
x~x
The relative error of x: ~
x
~
x f ( ~
x) =1 relative errors of x and f(x) are equal
CN >1 the error is amplified
f (~x) <1 the error is attenuated
18
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 4.7 Evaluate and interpret the condition numbers for
a) f ( x) x2 1 x for ~
x 300
b) f ( x) e x
for ~
x 10
Answer:
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Total Numerical Error
The total numerical error is the summation of the truncation and round-off
errors.
•The only way to minimize round-off errors is to increase the number of
significant figures of the computer. The round-off errors will increase due to
subtractive cancellation or due to an increase in the number of computations
in an analysis.
•The truncation errors can be reduced by decreasing the step size. A
decrease in step size can lead to subtractive cancellation or to an increase in
computation.
20
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
• Determine an appropriate step size for a particular computation.