You are on page 1of 18

Numerical Methods For Engineers

Lecture 2: Errors and Types of Errors


By
MD Irfan Ali
Thermal & Aerospace Program
School of Mechanical Chemical & Materials
Engineering

1
Contents

1. Error Definition
1.1 Absolute Error
1.2 Relative Error
2. Types of Computational Errors
2.1 Round Off Error
2.2 Truncation Error
2.3 Machine Epsilon Error
3. Numerical Instability
3.1 Inherent Instability
3.2 Induced Instability
2
Error Definition

𝐸𝑟𝑟𝑜𝑟 = 𝑇𝑟𝑢𝑒 𝑉𝑎𝑙𝑢𝑒 − 𝐴𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 𝑉𝑎𝑙𝑢𝑒

𝐴𝑏𝑠𝑜𝑙𝑢𝑡𝑒 𝐸𝑟𝑟𝑜𝑟 = 𝐸𝑟𝑟𝑜𝑟

𝐸𝑟𝑟𝑜𝑟
𝑅𝑒𝑙𝑎𝑡𝑖𝑣𝑒 𝐸𝑟𝑟𝑜𝑟 =
𝑇𝑟𝑢𝑒 𝑉𝑎𝑙𝑢𝑒

𝐸𝑟𝑟𝑜𝑟
%𝑅𝑒𝑙𝑎𝑡𝑖𝑣𝑒 𝐸𝑟𝑟𝑜𝑟 = 𝑋100
𝑇𝑟𝑢𝑒 𝑉𝑎𝑙𝑢𝑒

3
Problem Statement: Suppose that you have the task of measuring the lengths of
a bridge and a rivet and come up with 9999 and 9 cm, respectively. If the true
values are 10,000 and 10 cm, respectively, compute (a) the true error and (b)
the true percent relative error for each case.
Solution.
(a) The error for measuring the bridge is
Error = 10,000−9999 = 1 cm
and for the rivet it is
Error = 10−9 = 1 cm

(b) The percent relative error for the bridge is


% Relative Error =(1/ 10,000)*100 % = 0.01%
and for the rivet it is
% Relative Error = (1\10)*100 % = 10%

Thus, although both measurements have an error of 1 cm, the relative error for
the rivet is much greater. We would conclude that we have done an adequate
job of measuring the bridge, whereas our estimate for the rivet leaves
something to be desired.

4
Types of Computational Errors

1) Round Off Error:


It is a quantity ‘R’ which must be added to the finite representation of the
number in order to make it the true representation of that number.
Example:

1
= 0.3333; 𝑅 = 0.0000333 … .
3
Other examples are rational numbers, roots of most positive numbers.
Note: Round Off Error is not under the control of the user.

5
Types of Computational Errors contd…

2) Truncation Error:
It is a quantity ‘T’ which must be added to the representation of a quantity in
order to make this quantity exactly equal to the number. It arises due to the
use of approximate formulae based on Taylor’s series.
Example:

𝑥
𝑥2 𝑥3 𝑥4 𝑥𝑛
𝑒 =1+𝑥+ + + + ⋯……………….+ (𝑓𝑜𝑟 𝑠𝑚𝑎𝑙𝑙 𝑥)
2! 3! 4! 𝑛!
So, 𝑒 0.1 = 1.1 (𝑖𝑓 𝑜𝑛𝑙𝑦 𝑓𝑖𝑟𝑠𝑡 𝑡𝑤𝑜 𝑡𝑒𝑟𝑚𝑠 𝑎𝑟𝑒 𝑐𝑜𝑛𝑠𝑖𝑑𝑒𝑟𝑒𝑑) and
𝑒 0.1 = 1.105 (𝑖𝑓 𝑜𝑛𝑙𝑦 𝑓𝑖𝑟𝑠𝑡 𝑡ℎ𝑟𝑒𝑒 𝑡𝑒𝑟𝑚𝑠 𝑎𝑟𝑒 𝑐𝑜𝑛𝑠𝑖𝑑𝑒𝑟𝑒𝑑)
Note: Truncation Error is under the control of the user. If we need better
approximation, we can take more terms in the Taylor’s series.

6
Types of Computational Errors contd…

3) Machine Epsilon Error:


When a number is used, it is only accurate up to the accuracy of the machine.
Hence the error incorporated by the machine itself is known as Machine
epsilon error.
Example: The scientific calculator we use is accurate up to 10 significant digits
only.

7
Other Sources of Errors

1) Subtraction of two nearly equal numbers.


Example:
Let 𝑥 ∗ ≈ 𝑥, 𝑦 ∗ ≈ 𝑦 𝑎𝑛𝑑 𝑧 ∗ ≈ 𝑧
Suppose 𝑥 ∗ = 0.264593 × 101 , and absolute error in measuring is 0.5 ×
10−5 . 𝑦 ∗ = 0.264162 × 101 and absolute error in measuring is 0.5 × 10−5 .
0.5×10−5
So relative error in 𝑥 = ≈ 1.89 × 10−6
0.264593×101

0.5×10−5 +0.5×10−5
Now relative error in (𝑥 − 𝑦) is ≈ 2.32 × 10−3 , which is
0.000431×101

very large when compared to the relative error in ′𝑥′.

8
Other Sources of Errors

2) Division by a very small number.


Example:
1
Let 𝑓 𝑥 = 1−𝑥2 and we want to find the value of 𝑓 0.9 .
1
Exact value is 1−0.81 = 0.526316 × 101 .

Suppose if we commit error in measuring in 𝑥, 𝑖. 𝑒. 𝑥 ≈ 𝑥 ∗ = 0.900005, with


an error of 0.5 × 10−5.
1
Then 𝑓 𝑥 ∗ = 1−(0.900005)2 = 0.526341 × 101 .

Therefore, error in the 6th place of ′𝑥′ has produced error in the 5th place of
𝑓 𝑥 .

9
Numerical Instability

If the growth of error is under control i.e. bounded then the method gives
stable results. Otherwise, Numerical Instability occurs.

Numerical Instability can occur due to the following reasons:


a) Inherent Instability, and b) Induced Instability
In Inherent Instability the method itself is prone to cause errors whereas
Induced Instability occurs because of selection of wrong method.
Note: Induced Instability in the result is caused by the user.

10
Inherent Instability

Example of Wilkinson:
Finding the zeros of the polynomial: 𝑃20 = 𝑥 − 1 𝑥 − 2 … 𝑥 − 20
i.e. 𝑃20 = 𝑥 20 − 210𝑥 19 + ⋯ + 20!
Exact roots are: 1, 2, 3, …, 20.
Now change −210 𝑡𝑜 − (210 + 2−23 ), where 2−23 is of the order of
machine epsilon.
If we use the standard methods to find the roots, we obtain the smallest roots
with good accuracy.
Accuracy decreases as larger roots are obtained.
For 𝑟𝑜𝑜𝑡𝑠 ≥ 12, they become complex pairs.
This is an example of Inherent Instability.

11
Induced Instability
1 𝑥𝑛
Example: Evaluate 𝐼𝑛 = 0 𝑥+6
𝑑𝑥, 𝑛 = 1, 2, 3, … , 10

Using a recurrence relation we have:


1 𝑥 𝑛−1
𝐼𝑛−1 = 0 𝑥+6
𝑑𝑥 , and
1 1
𝑥 𝑛 + 6𝑥 𝑛−1 𝑥𝑛
𝑛 𝐼𝑛 + 6𝐼𝑛−1 = 𝑛 𝑑𝑥 = 𝑛[ ]0 = 1
0 𝑥 + 6 𝑛
1
1 𝑑𝑥 7
𝑠𝑜 𝐼𝑛 = − 6𝐼𝑛−1 𝑤𝑖𝑡ℎ 𝐼0 = = ln = 0.15415
𝑛 0 𝑥 + 6 6
𝑤𝑒 𝑜𝑏𝑡𝑎𝑖𝑛 𝐼1 = 1 − 6𝐼0 = 0.07510, 𝐼2 = 0.04940, 𝐼3 = 0.03693, … … … … …

𝐼8 = −1.09972, 𝐼9 = 6.70943 𝑎𝑛𝑑 𝐼10 = −40.15658


But 𝐼𝑛 → 0 𝑎𝑠 𝑛 → ∞.
The solution oscillates and explodes, this type of instability in the solution is
known as Induced Instability occurred because of wrong selection of the
method.

12
Induced Instability
1 𝑥𝑛
Example: Evaluate 𝐼𝑛 = 0 𝑥+6
𝑑𝑥, 𝑛 = 1, 2, 3, … , 10

Now lets evaluate the above integral by working backwards.

We know 𝐼𝑛 → 0 𝑎𝑠 𝑛 → ∞. So lets take 𝐼10 = 0 with the recurrence relation

1 1 1 1 1 1
𝐼𝑛−1 = 6 − 𝐼𝑛 and then 𝐼9 = 6 − 𝐼10 = 0.01666, 𝐼8 = 6 − 𝐼9 =
𝑛 10 9

0.01574, … . , 𝐼1 = 0.15415

Which is the exact result.

Hence selection of wrong method to solve a problem can also induce

instability in the result.

13
Quiz: Choose the best answer

1) The error that occurs in the result of the quantity 𝑒 0.05 sin 45 is
a) Truncation Error
b) Machine Epsilon Error
c) Round-off Error
d) None of them

Ans: a

Explanation: The above quantity is evaluated based on the Taylor’s series of


expansion.

14
Quiz: Choose the best answer

2
2) The error that occurs in the result of the quantity ′ 3 ′is

a) Truncation Error
b) Machine Epsilon Error
c) Round-off Error
d) None of them

Ans: c

Explanation: Since it is a non-terminating decimal.

15
Quiz: State True or False

Statement: Round-off error is under the control of the user.

Ans: False
Explanation: It is not under the control of the user, only truncation error is
under the control of the user.

16
Quiz: Fill in the blanks

1) The instability in the result caused by the selection of wrong method is


known as ________________________.
2) ________________________ is the error which is incorporated by the
calculating machine itself.
3) Wilkinson example of finding roots is the best example of _______________
instability.
4) The truncation error can be minimised by taking more number of terms in
_________________ series.

Answers:1) Induced; 2) Machine Epsilon error; 3) Inherent Instability;


4) Taylor’s

17
Summary
Following topics are covered in this lecture:
1. Error Definition
1.1 Absolute Error
1.2 Relative Error
2. Computational Errors
2.1 The Truncation Error
2.2 The Round-off Error
2.3 The Machine Epsilon Error
3. Numerical Instability
3.1 Inherent Instability
3.2 Induced Instability

18

You might also like