4 Chapter 2

advertisement
CHAPTER II: ERROR
In the practice of numerical analysis it is important to be aware that
computed solutions are not exact mathematical solutions. Perfect accuracy
in most computational processes is impossible. We must make certain
approximations, and this introduced errors.
The error in a computed quantity is defined as
Error = true value – approximate value
= xT  xA
Absolute error  true value  approximat e value
 xT  x A
The relative error is a measure of the error in relation to the size of the true
being sought:
Relative error 

error
true value
xT  x A
xT
True percent relative error,  t 
Approximat e percent ,  a 
relative error
true value  approximat e value
 100 %
true value
present approximat ion  previous approximat ion
 100 %
present approximat ion
CHAPTER II: ERROR
2.1
15
Round-off error ...................................................................................
There are two approaches to shorten a number that has more digits that can
be represented by the available floating point system. The first approach is to
chop the number by discarding any digits according to the system can
accommodate. The second method is to round the number, which is
originating from the fact that computers retain only a finite number of decimal
places during a calculation. Therefore the results of its arithmetic operations
are only approximations to the true results. In addition, because computers
use a base-2 representation, they cannot represent certain exact base-10
numbers precisely. The discrepancy introduced by this omission of
significant figures is called round-off error.
Example :
Numbers such as , e, or 3 cannot be expressed by a fixed number of
decimal places. Therefore they cannot be represented exactly by the
computer.
Consider the number . It is irrational, i.e. it has infinitely many digits after
the period:
 = 3.1415926535897932384626433832795.....
The round-off error computer representation of the number  depends on
how many digits are left out.
Let the true value for  is 3.141593.
Number of digits
Approximation
Absolute error
Percent relative
(Decimal digit)
for 
1
3.1
0.041593
1.3239%
2
3.14
0.001593
0.0507%
3
3.142
0.000407
0.0130%
errror
CHAPTER II: ERROR
2.2
16
Truncation error ..................................................................................
The notion of truncation error usually refers to errors introduced when a
more complicated mathematical expression is “replaced” with a more
elementary formula. This formula itself may only be approximated to the true
values, thus would not produce exact answers.
Truncation of an infinite series to a finite series to a finite number of terms
leads to the truncation error. For example, the Taylor series of exponential
function
x2 x3
xn
e x  1 x 

 ... 
2!
3!
n!
Check a few Taylor series approximations of the number ex, for x = 1, n = 2,
3 and 4. Given that e1 = 2.718281.
Order of n
Approximation for ex
Absolute error
Percent relative error
2
2.500000
0.218281
8.030111%
3
2.666667
0.051614
1.898774%
4
2.708333
0.00995
0.365967%
There are still some errors that are not directly connected with the numerical
methods themselves. These include blunders, formulation or model error,
and data uncertainly.
 Revision: Significant figure
The significant figures of a number are those that can be used with
confidence. They correspond to the number of certain digits plus one
estimate digit.
Example:
How many significant figures in the following numbers?
a. 0.3
1 significant figure
b. 0.03
1 significant figure
CHAPTER II: ERROR
17
c. 0.030
2 significant figures
d. 300
may be one, two or three significant figures,
depending on whether the zeros are known with
confidence.
e. 3  102
1 significant figure
f.
3.0  102
2 significant figures
g. 3.00  102
3 significant figures
The concept of significant figures will have relevance to the definition of
accuracy and precision:
Precision refers to how closely individual measured or computed values
agree with each other. Precision is governed by the number of digits being
carried in the numerical calculations
Accuracy refers to how closely a number agrees with the true value of the
number it is representing. Accuracy is governed by the errors in the
numerical approximation.
The concepts of precision and accuracy can be illustrated graphically as
follows:
Accuracy
(a) accurate & imprecise
(b) accurate & precise
(c) inaccurate & imprecise
(d) inaccurate & precise
Precision
CHAPTER II: ERROR
18
 Exersice 2:
1. Perform the following computations using
i.
four-digit rounding arithmetic
ii.
four-digit chopping arithmetic
a.
 2 3
5 8
7 1

12 6
b.  *  
1
7
2. Perform the following computations
i.
exactly
ii.
using three-digit chopping arithmetic
iii.
using three-digit rounding arithmetic
iv.
compute the absolute error in part ii and iii
v.
compute the relative error in part ii and iii
for
a. 133 +0.921
b.
2 9
c.     
9 7
e.
5e + 2 
d.
(12.5 – 0.343) – 11.6
5 4

12 7
2 3  4.5
3
7
3. Evaluate this cubic polynomial for x = 1.32, using chopping to three digits
at each arithmetic operation, and getting the relative errors:
3.12 x 3  2.11x 2  4.01x  10.3
CHAPTER II: ERROR
19
a. Do it proceeding from left to right.
b. Do it from right to left. Is the answer from a and b same?
c. Repeat part (a) but do it with “nested multiplication”. The nested form
is:
((3.12 x  2.11)x  4.01)x  10.3
4. Find the Maclaurin series for f(x) = e x . Use three terms of the series to
find an approximation to e 0.5 and the truncation error.
Hint :
e x  1 x 
1 2 1 3
1 4
x  x 
x  ...
2
6
24
5. Let
f (x) 
for    x  
x cos x  sin x
x  sin x
a. Use four-digit rounding arithmetic to evaluate f(0.1)
b. Replace each trigonometric function with its Maclaurin polynomial,
(use the first three terms of the series) and repeat part (a)
c. The actual value is f(0.1)= 1.9989998. Find the relative error for the
values obtained in parts (a) and (b).
Hint : Maclaurin series for
sin x  x 
x3 x5 x7


 ...
3!
5!
7!
cos x  1 
x2 x4 x6


 ...
2!
4!
6!
Download