Chapter I Error
Chapter I Error
Chapter one
INTRODUCTION
Numerical methods are methods for solving problems on computers by numerical calculations,
often giving a table of numbers and/or graphical representations or figures. Numerical methods
tend to emphasize the implementation of algorithms. The aim of numerical methods is therefore
to provide systematic methods for solving problems in a numerical form. The process of solving
problems generally involves starting from an initial data, using high precision digital computers,
following the steps in the algorithms, and finally obtaining the results. Often the numerical data
and the methods used are approximate ones. Hence, the error in a computed result may be caused
by the errors in the data, or the errors in the method or both.
Definition: Numerical method is the study of approximate analysis for solving problems of
mathematical analysis by means of arithmetic calculations.
Analysis of errors is the central concern in the study of numerical methods and therefore we
will investigate the sources of errors, the type of errors that may be occurring in the given
problem and the subsequent propagation of errors.
1.1. Sources of errors
The main sources of errors in obtaining numerical solutions to mathematical problems are:
a. The model: To solve different problems, mathematical models are formulated to describe
them and these models do not describe them exactly and as a result errors are introduced.
b. The numerical method: The methods used to solve the mathematical models are often
not exact and as a consequence errors are induced.
c. The data: There may be errors in measuring or estimating values.
d. The representation of numbers: A computer has a finite word length and so only a
fixed number of digits of a number are inserted and as a consequence errors are
introduced.
e. The arithmetic: Frequently errors are introduced in carrying out operations such as
addition and multiplication.
Page 1
Numerical Analysis I
Remark 1: There are two kinds of numbers which are exact and approximate numbers.
Example 1.1
a. The numbers 1,2,3, … , 1 2 , 3 2 , … , √2, 𝜋, 𝑒 and so on written in this manner are exact
numbers.
b. The numbers 3.1428, 3.14285714, 3.142857, 3.14286 and so on are approximate values
of the number 𝜋.
The digits that are used to express a number are called significant digits or significant
figures.
Example1. 2
a. The numbers 3.1416, 0.66667 and 4.0687 each contain five significant digits.
b. The numbers 0.00023, 3.4000 and 2.3 each contain two significant figures.
1.2. Approximation of errors
Classification of errors
1. Inherent errors: Most of numerical computations are inexact either due to the given data
or due to the limitations of the computing aids such as mathematical tables, desk
calculators or the digital computers. Due to these limitations numbers have to be rounded
causing errors called inherent (rounded – off) errors. These errors cannot be completely
removed but can be minimized if we select a better data and by using computing aids of
higher precision.
2. Truncation errors: The mathematical models may be algebraic or transcendental or
other types of equations. The solution of such equations may not be solved analytically,
hence we use numerical methods. In the process errors are induced and such errors are
called truncation errors. In general, truncation errors are errors due to the model and
method.
Page 2
Numerical Analysis I
With 𝑡 −digit computer a number with mantissa greater than 𝑡 −digits cannot be represented
exactly. Such number must be reduced to 𝑡 −digits and there are two ways of reducing the
number of digits of the given number.
a. Chopping: In a 𝑡 −digit computation, all digits of the number to the right of 𝑡 are
dropped – off.
𝑎 = 0. 𝑑 𝑑 … 𝑑
𝑥 =Sign(𝑎 × 10 )
𝑥 =Sign(𝑎 × 10 )
Page 3
Numerical Analysis I
𝑥 =Sign(𝑎 × 10 )
In both cases the resulted error in this process is given by the formula 𝑒 = |𝑥 − 𝑥 |.
Example1.3 Let 𝑥 = 0.142862 × 10 , 𝑡 = 4, then represent the number inside the computer
with the given capacity and find the error.
Therefore, the number becomes, 𝑥 = 0.1428 × 10 and the resulted error is given by:
Therefore, the number becomes, 𝑥 = 0.1429 × 10 and the resulted error is given by:
Absolute error: Is the numerical difference between the true value of a quantity and its
approximate value. i.e. if 𝑥 is the true value of a quantity and 𝑥 is its approximate value, then the
absolute error 𝐸 is given by:
𝐸 = |𝑥 − 𝑥 |
Example1. 4 Let the exact value or true value of the number is 20 3 and its approximate value is
6.666, then find the absolute error, relative error and the percentage relative error.
Page 4
Numerical Analysis I
𝑥−𝑥 20 − 6.666
𝐸 = = 3 = 1 10000
𝑥 20
3
Example 1.5 Three approximate values of the number 1 3 are given as 0.30, 0.33 and 0.34.
Which one of the three is the best approximation?
Solution: The value with the smallest absolute error is the best approximation and therefore we
have to find the absolute errors. Let 𝑥 = 0.30, 𝑥 = 0.33 and 𝑥 = 0.34
𝐸 = 1 3 − 0.30 = 1 30
𝐸 = 1 3 − 0.33 = 1 300
𝐸 = 1 3 − 0.34 = 1 150
Solution:
3.1428 − 𝜋 3.1428 −
𝐸 = = = 0.00001818
𝜋
Page 5
Numerical Analysis I
3.1428 − 𝜋 3.1428 −
𝐸 = = = 0.00001818
𝜋
Remark 2: If the number is rounded to 𝑁 decimal places, then the absolute error is given by:
1
∆𝑥 = × 10
2
Example 1.7 If 𝑥 = 0.51 and correct to two decimal places, then find the absolute error.
1
= × 10 = 0.005
2
Page 6
Numerical Analysis I
⇒ ∆𝑓(𝑥) = |𝑓 (𝑥)|∆𝑥
Where, ∆𝑓(𝑥) = |𝑓(𝑥) − 𝑓(𝑥)| represents an estimation of the error of the function 𝑓 and ∆𝑥 =
|𝑥 − 𝑥| represents an estimation of the error of 𝑥.
Example 1.8 Estimate the error committed in 𝑓(𝑥) = 𝑥 , when 𝑥 is approximated by 𝑥 = 2.5
with error ∆𝑥 = 0.01.
= 3(2.5) × 0.001
= 0.1875
So, it is essential to use numerical methods in programming problems on computers if and only
if the method is inherently efficient and good programmed.
Therefore, to solve problems using computers we have to follow the following steps.
1. Selection(choice) of a method
2. Designing(preparation) of algorithm
3. Flow charting
4. Programming
5. Execution of the program.
Selection of the method: Is the selection of a mathematical formula to the given problem to
find the solution. In this case, there may be more than one method available and hence only one
method must be chosen.
After the method has been decided a complete set of computational steps have to be followed in
a sequence and this sequence of steps is called an algorithm. A diagrammatic representation that
illustrates the sequence of steps to be performed to arrive at the solution is called a flow chart.
Page 7
Numerical Analysis I
We can summarize these commonly used symbols to represent these illustrations and their
meaning as
Computations
Decision making
For loops
Example1. 9 Develop the algorithm and draw the flow chart to solve a quadratic equation.
Solution: The quadratic equation is given by 𝑥 + 𝑏𝑥 + 𝑐 = 0. To solve this problem, first find
the descriminant = 𝑏 − 4𝑎𝑐 .
Case 1: Let 𝑑 is negative, then the roots are complex roots. That is
±√ ±√
𝑥= = and the roots are
| | | |
𝑥 = and 𝑥 =
Case 2: Let 𝑑 = 0, then the roots are real and equal and given by:𝑥 = −
Case 3: Let 𝑑 is positive, then we have two real roots and the roots are:
√ √
𝑥 = and 𝑥 =
Page 8
Numerical Analysis I
Algorithm
1. Input 𝑎, 𝑏, 𝑐
2. 𝑑 = 𝑏 ∗ 𝑏 − 4 ∗ 𝑎 ∗ 𝑐
3. If 𝑑 < 0
4. Cout the roots are imaginary
5. 𝑥 = −
6. 𝑥 = 𝑠𝑞𝑟𝑡(𝑎𝑏𝑠(𝑑))/2 ∗ 𝑎
7. Cout the roots are 𝑥 + 𝑖𝑥 , 𝑥 − 𝑖𝑥
8. Else if 𝑑 = 0
9. Cout the roots are equal and real
10. 𝑥 = −
∗
11. Cout 𝑥
12. Else
13. Cout the roots real and unequal
14. 𝑥 = (−𝑏 + 𝑠𝑞𝑟𝑡(𝑑))/2 ∗ 𝑎
15. 𝑥 = (−𝑏 − 𝑠𝑞𝑟𝑡(𝑑))/2 ∗ 𝑎
16. Cout 𝑥 , 𝑥
17. Stop
Page 9
Numerical Analysis I
Flow chart
Start
Input 𝑎, 𝑏, 𝑐
𝑑 =𝑏∗𝑏−4∗𝑎∗𝑐
Yes If 𝑑 < 0 No
No
Display equal
𝑏
𝑥 =− real roots
2∗𝑎 Display two
d/t real roots
𝑥 = 𝑠𝑞𝑟𝑡(𝑎𝑏𝑠(𝑑))/2 ∗a
−𝑏 𝑥 = (−𝑏 + 𝑠𝑞𝑟𝑡(𝑎𝑏𝑠(𝑑)))/2 ∗ 𝑎
𝑥=
Display,𝑥 + 2∗𝑎 𝑥 = (−𝑏 − 𝑠𝑞𝑟𝑡(𝑎𝑏𝑠(𝑑)))/2 ∗ 𝑎
𝑖𝑥 , 𝑥 − 𝑖𝑥
Display 𝑥 Display 𝑥 , 𝑥
Stop
Page 10