Errors in numerical computations
Dr. D. B. Gurung
Department of Natural Sciences (Mathematics)
Kathmandu University, Nepal
————————————————————————————————————
1 Numerical computing
Almost all the numerical methods computations are done using computers. Be-
cause of the use of computers in computation, some error are possible due to
truncation or round-off of a number. These errors are to be observed. In com-
puter, only a fixed number of digits can be stored.
Consider the value of 22
7
= 3.142857143 · · · . But a computer can store only a
fixed number of digits. The number of digits that can be stored depends upon
the word length of the computer. So the value will be 3.142857 for a computer
which permits only eight digits (including the decimal point). In this case the
exact value = 3.142857143 · · · . But the stored value = 3.142857. This causes an
error.
There are various characteristics of numerical computations. Some of them
are:
1. Error and approximate value: There are two kinds of numbers:
(a) Exact
(b) Approximate number
√
The numbers 2, 13 , 15 etc are exact and π, 2, e, · · · etc written in this form
√
are exact numbers. But when written
√ 2 in the digital form 1.41, 1.414, 1.4142
etc are approximate value of 2. Similarly, 3.14, 3.141, 3.14159, · · · etc are
all approximate values of π. Likewise 2.7, 2.71, 2.718, · · · etc are all approx-
imate value of e.
So, an approximate value is a value that differs but slightly from an exact
value and is used in place of later in calculations.
2. Significant figures (digits)
The figures (digits) that are used to express a number are called significant
figures (digits).
In a decimal number system, any number can be constructed using the
digits
0 , 1, 2, 3, 4, 5, 6, 7, 8, 9
|{z} | {z }
zero digit non zero digits
Rules to identify significant digits:
Rule 1: (Non zero digits)
Any of the non zero digits 1, 2, · · · , 9 in a number are always significant.
Rule 2: (Zero digit)
1
• leading zeros are never significant.
For example,
| {z } 524
0.000
leading zeros
Thus only the significant digits are 5, 2 and 4.
• imbedded zeros are always significant.
For example,
| {z } 52
0.000 00
|{z} 4
leading zeros imbedded zeros
Thus only the significant digits are 5, 2, 0, 0 and 4.
• trailing zeros (eg. 423 000
|{z} ) are significant if the decimal point
trailing zeros
is specified.
For example,
In the number 423 000
|{z}
trailing zeros
the significant digits are 4, 2 and 3.
In the number 423 000.
|{z}
trailing zeros with decimal
the significant digits are 4, 2, 3, 0, 0 and 0. So the number of significant
digits in the number 423000. is 6.
In the number 423 000.00
| {z }
trailing zeros with decimal
the significant digits are 4, 2, 3, 0, 0, 0, 0 and 0. So the number of sig-
nificant digits in the number 423000.00 is 8.
Remark: Changing the number to scientific notation M ×10n will be easier
to identify significant figures.
Example Number of Scientific notation Zero digit
significant
digits
0.00235 3 2.35 × 10−3 leading zeros
2.0074 5 2.0074 × 100 imbedded zeros
4200 2 4.2 × 103 trailing zeros
4200. 4 4.200 × 103 trailing zero
4200.0 5 4.2000 × 103 trailing zero
3. Round-off numbers
To round-off or simply round a number is to retain a certain number of
digits, counted from the left, and drop the others.
If a number is to be rounded off to n significant figures, discard all the digits
to the right of the nth digits under the following rules.
Rule 1: If the (n + 1)th digit is less than 5, leave the nth digit unchanged.
2
For example, 0.032521 becomes 0.0325 on rounding off to 3 significant digits.
Rule 2: If the (n + 1)th digit is greater than 5, increase the nth digit by 1.
For example, 2.3362 becomes 2.34 on rounding off to 3 significant digits.
Rule 3: If the (n + 1)th digit is 5, and is followed by digit other than zero,
then increase the nth digit by 1.
For example, 2.367501 becomes 2.368 on rounding off to 4 significant digits.
Rule 4: If the (n + 1)th digit is 5 or is followed by zeros only, then increase
the nth digit by 1 if it is odd, otherwise leave unchanged.
For example, 3.2350 becomes 2.24 on rounding off to 3 significant digits,
and the number 3.2650 becomes 3.26 on rounding off to 3 significant digits.
4. Erros in computations
By the error, we mean the difference between the exact value and approxi-
mate value.
Error (E) = Exact value (X) - Approximate value (X1 )
In any numerical computations, we come across the following types of errors.
(a) Round-off errors
Because of the limitation in the number of digits, we may round off
the numbers some times. The error due to rounding off the number is
called round-off error.
(b) Truncation errors
When the results are evaluated using computer, the results are trun-
cated to the required number of digits. For example, 1.8234516 may
be truncated as 1.823451. Truncation means cutting off the other dig-
its (no rounding off). The error due to truncation is called truncation
error.
(c) inherent error
In a numerical method calculations, we may have some basic math-
ematical assumptions for the simplifying the problem. Due to this
assumption some error is possible at the beginning of the process it-
self. This error is called inherent error.
5. Measurement of accuracy
(a) Absolute error (EA )
The absolute value of the error (E) is called the absolute error.
Absolute error = |Error|
EA = |E|
(b) Relative error (ER )
The relative error is the ratio of the absolute error to the absolute
3
value of exact value.
Absolute error
Relative error =
|Exact value|
EA
ER =
|E|
(c) Percantage error (Ep )
The percentage error Ep is given by
Ep = ER × 100 %
6. Absolute error for the sum, product and quotient of two numbers
Let a and b be any two numbers, and EA1 and EA2 be their respective absolute
errors.
(a) Sum
If EA be the absolute error of the sum a + b, then
EA = EA1 + EA2
In general
EA = EA1 + EA2 + · · · + EAn
for n numbers.
(b) Product
If EA be the absolute error of the product ab, then
EA = (a + EA1 ) + (b + EA2 )
Thus
EA = aEA2 + bEA1 + EA1 EA2
| {z }
<<1
EA ≈ bEA1 + aEA2
(c) Quotient
If EA be the absolute error of the quotient ab , then
a + EA1 a
EA = 2
−
b + EA b
Thus
bEA1 − aEA2 bEA1 − aEA2 bEA1 − aEA2 EA1 EA2
a
EA = = ≈ = −
b(b + EA2 )
2
E
b2 1 + bA b2 b a b
7. Upper limiting error of an approximate number
The upper limiting error of an approximate number denoted by ∆X of an
exact number X is any number not less than the absolute error EA of that
number. That is,
EA = |X − X1 | ≤ ∆X
4
Example 1 If a number 32.1245 is rounded to 32.12 correct to 4 significant
digits. Then
EA = |32.1245 − 32.12| = 0.0045
Observation 1:
1
∆X = (a unit at the 4th place of EA )
2
1
= × 0.01
2
= 0.005
Obviously
0.0045 = EA ≤ ∆X = 0.005
Observation 2:
The number 32.1245 is rounded to 32.12 correct to 4 significant figures, and
which is also correct to 2 decimal places.
1
∆X = (rounded to 2 decimal places)
2
1
= × 10−2
2
= 0.005
Obviously
0.0045 = EA ≤ ∆X = 0.005
Example 2 If a number 32.1256 is rounded to 32.13 correct to 4 significant
digits. Then
EA = |32.1245 − 32.13| = 0.0044
Observation 1:
1
∆X = (a unit at the 4th place of EA )
2
1
= × 0.01
2
= 0.005
Obviously
0.0044 = EA ≤ ∆X = 0.005
Observation 2:
The number 32.1256 is rounded to 32.13 correct to 4 significant figures, and
which is also correct to 2 decimal places.
1
∆X = (rounded to 2 decimal places)
2
1
= × 10−2
2
= 0.005
Obviously
0.0044 = EA ≤ ∆X = 0.005
5
Thus we can state the following theorems (omit proof).
Theorem 1 The absolute error, EA in a numerical computation correct to
n significant figures cannot be greater than half a unit in the nth place of
EA .
Theorem 2 If a number X is rounded to N decimal places, then
1
∆X = × 10−N
2
We further state the following theorem (omit proof)
Theorem 3 If the first significant figure of a number is k and the number
is correct to n significant figures, then the relative error, ER is less than
1/(k × 10n−1 ).
2 Arithmetic operations with significant figures
1. Rule for addition/subtraction
When adding or subtracting, round the answer to the least number of deci-
mal places.
4.7832
1.4572 0.0367
1.234
+83.21 -0.004322
+2.02
84.6672 0.032378
8.0372
Rounds to : 84.67 Rounds to : 0.0324
Rounds to : 8.04
2. Rule for multiplication/division
When multiplying or dividing, round the answer to the least number of
significant digits.
4.36
12.300 45.2
× 0.00013 = 534.7826087 = 7.1093775
0.0230 6.3578
0.0005668
Rounds to : 535 Rounds to : 7.11
Rounds to : 0.00057
Example 3 Obtain the range of values within which the exact value of
1.265(10.21 − 7.54)
47
lies, if all the numerical quantities are rounded off.
10.21
Solution: We have -7.54 Rounds to: 2.67
2.67
3.38
Then 1.265 × 2.67 = 3.37755. Rounding to 3 significant digits 3.38. Now
47
= 0.071914893 Rounding to 2 significant digits 0.072.
Example 4 Let the number a = 271.37 be correct to five significant digits. Here
the first significant figure k is 2 and the number of significant figures n is 5. Then
ER ≤ 1/(2 × 105−1 ) = 0.00005.
6
3 A general error formula
Let
u = f (x1 , x2 , · · · , xn )
be a function of several variables xi (i = 1, 2, · · · , n) and let the error in each xi
be ∆xi . Then the error ∆u in u is given by
u + ∆u = f (x1 + ∆x1 , xn + ∆xn , · · · , xn + ∆xn )
Expanding right hand side by Taylor series, we obtain
n
X ∂f
u + ∆u = f (x1 , · · · , xn ) + ∆xi + terms involving (∆xi )2
i=1
∂x i
Assuming that ∆xi is very small for all i = 1, · · · , n we can neglect the square
and higher powers of ∆xi . Thus
n
X ∂f ∂f ∂f ∂f
∆u ≈ ∆xi = ∆x1 + ∆x2 + · · · + ∆xn
i=1
∂xi ∂x1 ∂x2 ∂xn
which is the same at total differential of u. Clearly
∂f ∂f ∂f
(∆u)max = ∆x1 +
∆x2 + · · · +
∆xn
∂x1 ∂x2 ∂xn
and
|∆u| ∂f ∆x1 ∂f ∆x2 ∂f ∆xn
ER = = + + ··· +
|u| ∂x1 u ∂x2 u ∂xn u
Example 5 Prove that the relative error of a product of three non-zero numbers
does not exceed the sum of the relative errors of the given numbers.
Solution Suppose the three non-zero numbers be a, b, c have errors ∆a, ∆b, ∆c
respectively. Let
u = abc
then
∂u ∂u ∂u
= bc, = ac, = ab
∂a ∂b ∂c
The relative error ER in u is given by
|∆u| ∂f ∆a ∂f ∆b ∂f ∆c
ER = = + +
|u| ∂a u ∂b u ∂c u
∆a ∆b ∆c
= bc + ac + ab
abc abc abc
∆a ∆b ∆c
= + +
a b c
∆a ∆b ∆c
≤ + +
a b c
= ERa + ERb + ERc
7
Example 6 If y = 3x7 − 6x, find the percentage error in y at x = 1 if the error
in x is 0.05.
Solution Consider
y = f (x) = 3x7 − 6x
Then
dy
= 21x6 − 6
dx
and so
dy
= 15
dx x=1
and
y(1) = f (1) = 3 − 6 = −3(true value)
Error in y is
dy
∆y x=1
= = 15 × 0.05 = 0.75
dx x=1
Relative error in y is
|∆y| 0.75
ER = = = 0.25
| − 3| 3
Therefore, percentage error
Ep = ER × 100% = 0.25 × 100 = 25%
5xy 2
Example 7 If u = z3
. Find (ER )max for ∆x = ∆y = ∆z = 0.001 and x = y =
z = 1.
Solution Here
∂u 5y 2 ∂u 10xy ∂u 15xy 2
= 3, = 3 , =− 4
∂x z ∂y z ∂x z
and
5y 2 10xy 15xy 2
∆u = + 3 −
z3 z z4
In general, the errors ∆x = ∆y and ∆z may be positive or negative, and hence
we take the absolute values of the terms on the right side. This gives
2
5y 10xy 15xy 2
(∆u)max ≈ ∆u = 3 + 3 + − 4
z z z
Now for ∆x = ∆y = ∆z = 0.001 and x = y = z = 1, the relative maximum error
(ER )max is given by
(∆u)max 0.03
(ER )max = = = 0.006.
u 5