Ch. 4 Roundoff and Truncation Errors
Ch. 4 Roundoff and Truncation Errors
CHAPTER OBJECTIVES
The primary objective: Major sources of errors in numerical methods.
Specific objectives:
1. Understanding about accuracy and precision.
2. Quantify error.
3. Error estimation to decide when to terminate an iterative calculation.
4. Understanding how roundoff errors occur (Limitation of digital computers to represent numbers).
5. Recognizing that truncation errors occur (Exact mathematical formulations are represented by
approximations.)
6. Knowing how to use the Taylor series to estimate truncation errors.
7. Understanding how to write forward, backward, and centered finite-difference approximations of
first and second derivatives.
8. Recognizing that efforts to minimize truncation errors can sometimes increase roundoff errors.
Precision:
How closely individual approximation agree with each other approximation.
FIGURE 4.1
An example from marksmanship illustrating the concepts of accuracy and precision:
(a) inaccurate and imprecise, (b) accurate BUT imprecise, (c) inaccurate BUT precise, and (d) accurate AND
precise.
4.1.2 Error Definitions
Conclusion: Conclusion:
The 1 cm error is considered a small an acceptable The 1 cm error is considered BIG and UNACCEPTABLE
error. error.
Case A Case B
Error of 1 cm Error of 1 cm
Tower height Pipe diameter
The design height is 300 m The design is 2 cm diameter
The real tower is 299.99 m The real pipe is 1 cm diameter
There is 1 cm error There is 1 cm error
Conclusion: Conclusion:
The 1 cm error is considered BIG and
error. UNACCEPTABLE error.
Stopping criterion
Chapter 4 Roundoff and Truncation Errors
Thus, as more terms are added in sequence, the approximation becomes a better and better estimate of the
true value of ex. Equation (E4.1.1) is called a Maclaurin series expansion.
Starting with the simplest version, ex = 1, add terms one at a time in order to estimate e0.5. After each new
term is added, compute the true and approximate percent relative errors with Eqs. (4.3) and (4.5),
respectively. Note that the true value is e0.5 = 1.648721 . . . . Add terms until the absolute value of the
approximate error estimate a falls below a prespecified error criterion s conforming to three significant
figures (n = 3).
Solution.
True value of e0.5 = 1.648721
Stopping criterion
1st - Next
2nd Next
3rd Next
4th Next
5th Next
STOP
4.2 ROUNDOFF ERRORS
Example:
n = 0 to 6
Order
6
Chapter 4 Roundoff and Truncation Errors
PROBLEMS
4.10 The following infinite series can be used to approximate ex:
(a) Prove that this Maclaurin series expansion is a special case of the Taylor series expansion
(Eq. 4.13) with xi = 0 and h = x.
(b) Use the Taylor series to estimate f(x) = e x at xi+1 = 1 for xi = 0.25. Employ the zero-, first-,
second-, and third-order
Solution
(a) The Taylor series expansion
Become
For
We get
It is proven.
(b) Taylor series
True value
Order
3
4.11 The Maclaurin series expansion for cos x is
Starting with the simplest version, cos x = 1, add terms one at a time to estimate .
After each new term is added, compute the true and approximate percent relative errors.
Use your pocket calculator or MATLAB to determine the true value. Add terms until the
absolute value of the approximate error estimate falls below an error criterion conforming
to two significant figures.
True value
Order Status
1 Next
2 Next
3 STOP
Chapter 4 Roundoff and Truncation Errors
PROBLEMS
4.12 Perform the same computation as in Prob. 4.11, but use the Maclaurin series
Solution
True value
Order Status
1 Next
2 STOP
4.13 Use zero- through third-order Taylor series expansions to predict f (3) for
using a base point at x = 1. Compute the true percent relative error t for each
approximation.
Solution
The Taylor series expansion
True value
Order
3
4.15 Use zero- through fourth-order Taylor series expansions to predict f(2) for f(x) = ln x
using a base point at x = 1. Compute the true percent relative error t for each
approximation. Discuss the meaning of the results.
Solution
The Taylor series expansion
True value
Order
3
4
Solution
True value
Order Status
1 Next
2 Next
3 STOP
Chapter 4 Roundoff and Truncation Errors
PROBLEMS
4.19 To calculate a planet s space coordinates, we have to solve the function
Solution
Determine the highest-order Taylor series.
Maximum error of 0.015.
True value
1
2
The highest-order Taylor series expansion with maximum error of 0.0099 is the 4th order.
at x = 0.5 using a step size h = 0.5. Repeat the computation using h = 0.25. Note that the
derivative can be calculated directly as
Solution
Use forward difference