0% found this document useful (0 votes)
31 views36 pages

1.2 Numerical Errors

Numerical methods slide ch1.2

Uploaded by

Ibrahim Abadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views36 pages

1.2 Numerical Errors

Numerical methods slide ch1.2

Uploaded by

Ibrahim Abadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Physical measurements involve errors and every physical

measurement is an approximation. This leads us to a new


question:
How much error is involved in any given measurement?
The terms precision and accuracy relate to how good an
approximation is.

Accuracy is telling the truth

Precision is telling the same story over and


over again
Numerical Methods 2
Accurate, imprecise

The degree of conformity with a standard (the "truth"). Accuracy


relates to the quality of a result, and is distinguished from precision,
which relates to the quality of the operation by which the result is
obtained. The marksman has approached the "truth", although
without great precision. It may be that the marksman will need to
change the equipment or methodology used to obtain the result if a
greater degree of precision is required, as he has reached the
limitations associated with his equipment and methodology.

Numerical Methods 3
Precise, Inaccurate Accuracy with Precision

The degree of perfection in the instruments and methods used to


obtain a result. An indication of the uniformity or repeatability of a
result. Precision relates to the quality of an operation by which a
result is obtained. The marksman has achieved a uniformity,
although it is inaccurate. With the knowledge gained by observation
of the results, the marksman can apply a systematic adjustment (aim
lower and to the left of his intended target, or have his equipment
adjusted) to achieve more accurate results in addition to the
precision that his methodology and equipment have already attained.

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

easy to detect the the blunder may go


blunder undetected and uncorrected

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.

True Error (Et) = True Value – Approximate Value

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

a) Find the approximate value of f ' ( 2)


b) True value of f ' (2)
c) True error for part (a)

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.

Approximate Error (Ea ) Present Approximation – 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%

Absolute relative approximate errors may also need to be


calculated,
a =| −0.0389421| = 0.0389421 or 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

0.10 9.75585 1.27103 1

0.01 9.53781 2.28605 1

0.001 9.51637 0.22536 2

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.).

Solution Algorithm (part a)

1. Calculate the true value of cos(0.5)


2. Assume an approximation order (for equ. 1) of i=1 ,
3. Find approximate value of cos (0.5) at this order of approximation
4. Calculate absolute relative approximate error |εa|%
5. Calculate the least number of S.D. (m)
6. If m<3 increase approximation order by 1 and go to step 3 otherwise stop

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

(b) cos(0.5) correct for at least 3 significant digits


No. of Min. (S.D.)
f(0.5) |ɛa|%
terms (m)
1 1 - 0
2 0.87500 14.28571 0
3 0.87760 0.29674 2
4 0.87758 0.00247 4 4 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:

1. Round off errors: caused by representing


numbers approximately
2. Truncation errors: caused by approximating
mathematical procedures.
Inaccuracies of numerical computations due to the
errors result in a deviation of a numerical solution
from the exact solution, no matter whether the
latter is known explicitly or not.

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...

However, this is not an exact representation. In fact,


it would need infinite numbers of bits to represent
1/10 exactly.
1
Et (0 2 1 0 2 2
0 2 3
1 2 4
... 1 2 22
0 2 23
0 2 24
)
10
9.537 10 8 sec
Round off error is: 9.5x10-8 seconds/measurement.

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.

• The shift calculated in the ranging system of


the missile was 687 meters.
• The target was considered to be out of range
at a distance greater than 137 meters.

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

Figure 1. Approximate derivative using finite Δx

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

The actual value is


f ' ( x ) = 2 x, f ' (3) = 2  3 = 6

Truncation error is then, 6 − 6.2 = −0.2


Find the truncation error with x 0.1?

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

You might also like