Computational Methods - Error Analysis
Computational Methods - Error Analysis
CHAPTER 1 INTRODUCTION
types of error,
ways of error reduction,
types of software that are used to solve computational problems using
numerical methods.
1. ERROR ANALYSIS
Definition of Error
An error, e in Numerical Mathematics is the difference between the actual value (Exact
value) and its computed value. If x* represents the computed value of a quantity, the
actual value for which is x, then the difference:
Absolute Error
Relative Error
eabs
erel
x
x x*
x
KCY/NOORSHAHIDA/THL Page | 1
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1
Types of Error
Round-off Error
Chopping Error
Number x is chopped to n digits when all digits that follow the n-th digit are
discarded and none of the remaining n digits is changed.
Truncation Error
Truncation error is defined as the replacement of one series by another with fewer terms.
The error arising from this approximation is called the truncation error.
Example: The infinite Taylor Series
exp x 2 1 x 2
x 4 x 6 x8
2! 3! 4!
...
x 2n
n!
...
might be replaced with the first 5 terms: exp x 2 1 x 2
x 4 x6 x8
2! 3! 4!
Example 1: Given an actual value, x = 1.485642 and its computed value, x* = 1.492101.
Find the following.
(a) Absolute error (b) Relative error
eabs
erel
eabs x x * x
1.485642 1.492101 0.006459
- 0.006459 1.485642
0.006459 0.00434762
KCY/NOORSHAHIDA/THL Page | 2
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1
Example 2: Round-off the actual value, x = 22/7 to five decimal places and find its
absolute error.
22
x 3.142857143... eabs x x *
7
x* ______________
Example 3: Chop the actual value, x = 22/7 to five decimal places and find its relative
error.
22 x x*
x 3.142857143... erel
7 x
x* ______________
2. ERROR REDUCTION
Nested Form
For polynomial evaluation, the rearrangement of terms into nested form will sometimes
produce a better result. In nested form, each power of x is factored out as far as it will go.
The nested form of a polynomial function is given in (2.2).
KCY/NOORSHAHIDA/THL Page | 3
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1
Example 4: Consider the following polynomial function with the given value x.
KCY/NOORSHAHIDA/THL Page | 4
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1
Polynomial Function
Nested Form
KCY/NOORSHAHIDA/THL Page | 5
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1
**Accuracy loss due to the round-off and chopping errors can be reduced by rearranging
the polynomial function into nested form.
Loss of significance occurs when nearly equal numbers are subtracted. Consider two
numbers which are nearly equal, p 0.31415926536 and q 0.31415957341 .
p q 0.31415926536 0.31415957341
0.0000030805
After subtraction, their difference is 0.0000030805 with only FIVE decimal digits of
significance. This phenomenon is called loss of significance. There are various
techniques that can be used to avoid loss of significance such as the use of rationalization
and Taylor series.
Rationalization
Rationalizing is removing the radical in the numerator or denominator:
f ( x) x 4 2
( x 4 2)
= ( x 4 2)
( x 4 2)
x
( x 4 2)
As as result, this prodecure allows original terms to be cancelled off and thereby
removes the subtraction.
KCY/NOORSHAHIDA/THL Page | 6
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1
ii) Rewrite the given function in a way that avoids the loss of significance:
( x 1 x)
f ( x) x( x 1 x ) *
( x 1 x)
x
=
x 1 x )
iii) Approximation of f (500) for f ( x) from (ii) correctly to six-digit and rounding:
500
f (500)
501 500)
=11.1748
iv) Compare the results of (i) and (iii). The actual value is 11.1748.
For (i), eabs x x * 11.1748 11.1500 0.0248
For (ii), eabs x x * 11.1748 11.1748 0
**Accuracy loss due to the round-off can be reduced by avoiding loss of significant digits.
Taylor series can be used to remove the subtraction from the nearly equal numbers’
subtraction. The terms can be converted into the Taylor series. The Taylor series
expansion for some Trigonometry functions is given in the following.
x3 x5
sin x x ...
3! 5!
x2 x4
cos x 1 ...
2! 4!
x3 2x5
tan x x ...
3 15
KCY/NOORSHAHIDA/THL Page | 7
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1
f ( x) tan x sin x
i) Rewrite the given function to avoid loss of significance by using first two nonzero
terms in the Taylor series expansion:
x3 x3
f ( x) ( x ) (x )
3 3!
1
= x3
2
ii) Approximation of f (0.0125) for f ( x) from (i) correctly seven-digit and rounding:
1
f (0.0125) (0.0125)3
2
= 106
iii) Find the absolute error given that actual value is 9.766 x107 .
KCY/NOORSHAHIDA/THL Page | 8
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1
3. INTRODUCTION TO SOFTWARE
Programming languages such as C, C++ and Java can be used to solve the numerical or
mathematical problems. However, interactive computing environments such as FreeMat,
Octave and MATLAB provide powerful, built-in mathematical capabilities and a very
high-level programming language for rapid mathematical problem solving. FreeMat is a
free open source numerical computing environment and programming language, similar
to MATLAB and GNU Octave. FreeMat integrates extensive mathematical capabilities,
especially in linear algebra, with powerful scientific visualization, a high-level
programming language and a variety of toolboxes.
FreeMat is chosen in this course due to the several reasons as stated below:
KCY/NOORSHAHIDA/THL Page | 9