1.2 Numerical Errors
1.2 Numerical Errors
Numerical Methods 3
Precise, Inaccurate Accuracy with Precision
Numerical Methods 4
An additional benefit can be obtained by using a methodology
that yields great precision. The analysis of results obtained from
techniques yielding a high degree of precision will make the
detection of blunders easier.
Now if we introduce a blunder into the results associated with
accuracy and with precision.
Precision with blunder Accuracy with blunder
Numerical Methods 5
1) To determine the accuracy of numerical
results.
2) To develop stopping criteria for iterative
algorithms.
Numerical Methods 6
Defined as the difference between the true
value in a calculation and the approximate
value found using a numerical method etc.
Et = TV - AV
Numerical Methods 7
The derivative, f (x) of a function f (x) can be
approximated by the equation,
f ( x + h) − f ( x)
f ' ( x)
h
If f ( x) = 7e and h = 0.3
0 .5 x
Numerical Methods 8
Solution:
a) For x = 2 and h = 0.3
f (2 + 0.3) − f (2)
f ' ( 2)
0.3
f (2.3) − f (2)
=
0.3
7 e 0 .5 ( 2 .3 ) − 7 e 0 .5 ( 2 )
=
0 .3
22.107 − 19.028
= = 10.26459
0.3
Numerical Methods 9
Solution (contd.):
b) The exact value of f ' (2) can be found by using
our knowledge of differential calculus.
f ( x ) = 7 e 0 .5 x
f ' ( x ) = 7 0 . 5 e 0 .5 x
= 3.5e 0.5 x
So the true value of f ' ( 2) is
f ' ( 2) = 3.5e 0.5( 2 )
= 9.51399
True error is calculated as
Et = TV – AV
= 9.51399 − 10.26459 = −0.75060
Numerical Methods 10
Defined as the ratio between the true
error, and the true value.
True Error
Relative True Error (t ) =
True Value
TV - AV Et
t = =
TV TV
Numerical Methods 11
Following from the previous example for true error,
find the relative true error for f ( x ) = 7e 0.5 x at f ' (2)
with h = 0.3
From the previous example,
Et = −0.722
Relative True Error is defined as
True Error
t =
True Value
−0.75060
= = −0.07889
9.51399
as a percentage,
t = −0.07889 100% = −7.88940%
Numerical Methods 12
What can be done if true values are not known
or are very difficult to obtain?
Approximate error is defined as the difference
between the present approximation and the
previous approximation.
Ea AVnew AVold
Numerical Methods 13
For f ( x) = 7e 0.5 x at x = 2 find the following,
a) f (2) using h = 0.3
b) f (2) using h = 0.15
c) approximate error for the value of f (2) for part b)
Solution:
a) For x = 2 and h = 0.3
f ( x + h) − f ( x)
f ' ( x)
h
f (2 + 0.3) − f (2)
f ' ( 2)
0.3
Numerical Methods 14
Solution: (cont.)
f (2.3) − f (2)
=
0.3
7 e 0 .5 ( 2 .3 ) − 7 e 0 .5 ( 2 )
=
0 .3
22.107 − 19.028
= = 10.26459
0.3
b) For x = 2 and h = 0.15
f (2 + 0.15) − f (2)
f ' (2)
0.15
f (2.15) − f (2)
=
0.15
Numerical Methods 15
Solution: (cont.)
7e 0.5( 2.15) − 7e 0.5( 2)
=
0.15
20.50995 − 19.02797
= = 9.87985
0.15
c) So the approximate error, E a is
E a = Present Approximation – Previous Approximation
= 9.87985 − 10.26459
= −0.38474
Numerical Methods 16
Defined as the ratio between the approximate
error and the present approximation.
Approximate Error
Relative Approximate Error (εa) =
Present Approximation
AVnew AVold
a
AVnew
Numerical Methods 17
For f ( x) = 7e 0.5 x at x = 2 , find the relative approximate
error in f ’(x) using values from h = 0.3 and h = 0.15
Solution:
From Example 3, the approximate value of f (2) = 10.263
using h = 0.3 and f (2) = 9.87985 using h = 0.15
Ea = 0.38474
Approximate Error −0.38474
a = = = −0.0389421
Present Approximation 9.87985
as a percentage,| a
|% 0.0389421 100% 3.89421%
Numerical Methods 18
x x where x : implied precision
x= . ( sd = 3, m = sd + 1 = 4 )
0.5(0.01) = 0.5 10 −2 = 0.5 10 2− m
Numerical Methods 19
Method (1)
Given a pre-specified tolerance, s then
If |a | s no further iterations are necessary and the process
is stopped.
Method (2)
If at least m significant digits are required to be
correct in the final answer, then
2 m
| a| % (0.5 10 )
or
m 2 - log10 2 a
%
Numerical Methods 20
For f ( x ) = 7 e 0 .5 x at x = 2 with varying step size, h
h f (2) a
% m
0.3 10.26460 N/A 0 m 2 − log10 ( 2 a % )
2 − log10 (2 x3.89421)
0.15 9.87985 3.89421 1 1.10855
Numerical Methods 21
Knowing the cosine function can be approximated by the following infinite
series: 2 4 6 2i − 2
x x x x
cos x = 1 − + − + + (−1)i −1 Equ (1)
2! 4! 6! (2i − 2)!
i in the equation represents the order of the approximation
(a) Calculate the value of cos(0.5) with a relative approximate error of less than 1%.
(b) Recalculate cos(0.5) for a solution correct for at least 3 significant digits (S.D.).
Numerical Methods 22
(a) cos(0.5) for a solution with a |ɛa |% of less than 1%
No. of
f(0.5) |ɛa|%
terms
1 1 -
2 0.87500 14.28571
3 0.87760 0.29674 3 terms are needed
Numerical Methods 23
There are several potential sources of errors in a
numerical calculation. Two sources are universal in
the sense that they occur in any numerical
computation. They are:
Numerical Methods 25
Numbers are represented in a computer by a finite number
of digits of precision. The simplest variant for hardware
implementation is to keep the first n digits and to chop off
all remaining digits. A more accurate scheme is to
examine the (n+1)st digit and to round the nth digit to the
nearest integer. This procedure leads to round-off errors.
1
0.333333...333333
3
2 1.41421356237...
3.14159265...
Numerical Methods 26
Time is saved in a register that has 24 bits length.
Since the internal clock of the system is measured for
every one-tenth of a second, 1/10 is expressed in a 24
bit-register as 0.000110011001100110011001...
Numerical Methods 27
• The battery was on for 100 consecutive
hours, thus causing an inaccuracy of
No of measurements × Error per measurement
3600s 1 meas. 9.5 10 8 s
100hr = 0.342s
1hr (1 / 10 sec) 1 meas.
Numerical Methods 28
Error caused by truncating or approximating a
mathematical procedure.
Numerical Methods 29
Taking only a few terms of a Maclaurin series to
x
approximate e
2 3
x x
e x = 1 + x + + + .......... ..........
2! 3!
If only 3 terms are used,
x 2
Truncation Error = e − 1 + x +
x
2!
Numerical Methods 30
Using a finite x to approximate f (x)
f ( x + x) − f ( x)
f ( x)
x
the truncation error is caused by
choosing a finite value of x as
opposed x→0
secant line
P
tangent line
Numerical Methods 31
Using finite rectangles to approximate an integral.
32
Numerical Methods
1.2
Calculate the value of e with an absolute
relative approximate error of less than 1%.
1.2 2 1.2 3
e 1.2
= 1 + 1.2 + + + .......... .........
2! 3!
n
e1.2 Ea a %
1 1 __ __
2 2.2 1.2 54.545
6 terms are required. How
3 2.92 0.72 24.658
4 3.208 0.288 8.9776
many are required to get at least
5 3.2944 0.0864 2.6226 1 significant digit correct in
6 3.3151 0.020736 0.62550 your answer?
Numerical Methods 33
f ( x + x) − f ( x)
Find f (3)
for f ( x) = x 2 using f ( x)
x
and x = 0.2
f (3 + 0.2) − f (3)
f (3) =
'
0.2
f (3.2) − f (3) 3.2 2 − 32 10.24 − 9 1.24
= = = = = 6.2
0.2 0.2 0.2 0 .2
Numerical Methods 34
Use two rectangles of equal width to approximate
the area under the curve for
f ( x ) = x 2 over the interval [3,9]
y
9
x dx
90 2
y = x2
60
30
0 x
0 3 6 9 12
Numerical Methods 35
Choosing a width of 3, we have
9
x 2dx (x 2 ) (6 3) (x 2 ) (9 6)
x 3 x 6
3
= (3 2 )3 + (6 2 )3
= 27 + 108 = 135
Actual value is given by
9 9
x 3 93 − 33
3 x dx = 3 = 3 = 234
2
3
Truncation error is then
234 − 135 = 99
Find the truncation error with 4 rectangles?
Numerical Methods 36