Chapter 1 Introduction: in This Chapter, You Will Learn
Chapter 1 Introduction: in This Chapter, You Will Learn
Chapter 1: Introduction
CHAPTER 1 INTRODUCTION
In this Chapter, you will learn:
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
e|¿|
e rel = ¿
| x|
|x−x ¿|
¿
|x|
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 1
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction
Types of Error
Round-off Error
Round-off error is an error to introduce by rounding off numbers to limited number decimal
places.
Chopping Error
Number x is chopped to n digits when all digits that follow the nth 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
4
2 2 x x6 x8 x2 n
exp ( x )=1+ x + + + +…+ +…
2 ! 3! 4 ! n!
x4 x6 x8
might be replaced with the first 5 terms:exp ( x 2 )=1+ x 2 + + +
2 ! 3! 4 !
Example 1: Given an actual value, x = 1.485642 and its computed value, x* = 1.492101.
Find the following.
¿|1.485642−1.492101|
¿|−0.006459|
¿ 0.006459
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 2
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction
22
Example 2: Round-off the actual value, x= to five decimal places and find its absolute error.
7
22
x= =3.142857143 …
7
x ¿=3.14286
e|¿|=|x− x |¿
¿
¿|3.142857143−3.14286|
¿|−0.000002857|
¿ 0.000002857
22
Example 3: Chop the actual value, x= to five decimal places and find its relative error.
7
22
x= =3.142857143 …
7
x ¿=3.14285
e|¿|
e rel = ¿
| x|
|3.142857143−3.14285|
¿
|3.142857143|
|0.000007143|
¿
|3.142857143|
0.000007143
¿
3.142857143
¿ 0.000002272
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).
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 3
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction
Example 4: Consider the following polynomial function with the given value x.
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 4
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction
¿−15.8+1.5
¿−14.3
Polynomial Function
Nested Form
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 5
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction
** 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
f ( x )= √ x +4−2
( √ x + 4+2 )
¿ ( √ x+ 4−2 )
[ ( √ x + 4+2 ) ]
x
¿
( √ x + 4+2 )
As a result, this procedure allows original terms to be cancelled off and thereby removes the
subtraction.
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 6
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction
f ( x )=x ( √ x+1−√ x )
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.
** 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.
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 7
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction
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 1 3
( )(
f ( x ) = x+
3
− x−
3! 2
= x )
ii) Approximation of f (0.0125) for f (x) from (i) correctly seven-digit and rounding:
1
f ( 0.0125 )= ( 0.0125 )3
2
¿ 10−6
iii) Find the absolute error given that actual value is 9.766 ×10−7.
e|¿|=|x− x |¿
¿
¿|9.766 × 10−7−10−6|
¿−2.34 ×10−8
Programming languages such as C, C++ and Java can be used to solve the numerical or
mathematical problems. However, interactive computing environments such as MATLAB,
Maple and Mathematica provide powerful, built-in mathematical capabilities and a very high-
level programming language for rapid mathematical problem solving. One of the most widely
used computing environments is MATLAB, which is a proprietary product of The MathWorks,
Inc. MATLAB, which stands for MATrix LABoratory, is an interactive system that integrates
extensive mathematical capabilities, especially in linear algebra, with powerful scientific
visualization, a high-level programming language and a variety of toolboxes.
MATLAB is chosen in this course due to the several reasons as stated below:
i) Consistency: Functions have been commented by several researchers are highly consistent in
MATLAB, making it easier to return to coding in MATLAB after a break.
ii) Superior built-in documentation: MATLAB provides a good documentation.
iii) Existing packages and models: it seems like MATLAB is well established as substantial
existing code to guide subsequent researchers.
iv) MATLAB is user friendly for implementing matrix algebra based calculations.
v) Easier to pick up for the beginning users to learn and use the software to solve the numerical
problems.
Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 8
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7