Page 44 - Applied Numerical Methods Using MATLAB
P. 44
COMPUTER ERRORS VERSUS HUMAN MISTAKES 33
>> nm122
At x= 1, f1(x)=0.414213562373095150, f2(x)=0.414213562373095090
At x= 10, f1(x)=0.488088481701514750, f2(x)=0.488088481701515480
At x= 100, f1(x)=0.498756211208899460, f2(x)=0.498756211208902730
At x= 1000, f1(x)=0.499875062461021870, f2(x)=0.499875062460964860
At x= 10000, f1(x)=0.499987500624854420, f2(x)=0.499987500624960890
At x= 100000, f1(x)=0.499998750005928860, f2(x)=0.499998750006249940
At x= 1000000, f1(x)=0.499999875046341910, f2(x)=0.499999875000062490
At x= 10000000, f1(x)=0.499999987401150920, f2(x)=0.499999987500000580
At x= 100000000, f1(x)=0.500000005558831620, f2(x)=0.499999998749999950
At x= 1000000000, f1(x)=0.500000077997506340, f2(x)=0.499999999874999990
At x= 10000000000, f1(x)=0.499999441672116520, f2(x)=0.499999999987500050
At x= 100000000000, f1(x)=0.500004449631168080, f2(x)=0.499999999998750000
At x= 1000000000000, f1(x)=0.500003807246685030, f2(x)=0.499999999999874990
At x= 10000000000000, f1(x)=0.499194546973835970, f2(x)=0.499999999999987510
At x= 100000000000000, f1(x)=0.502914190292358400, f2(x)=0.499999999999998720
sqrt(x+1) = 31622776.6016838100000, sqrt(x) = 31622776.6016837920000
diff=0.00000001862645149230957, sum=63245553.20336760600000000000000
1.2.3 Absolute/Relative Computing Errors
The absolute/relative error of an approximate value x to the true value X of a
real-valued variable is defined as follows:
ε x = X(true value) − x(approximate value) (1.2.7)
X − x
ε x
ρ x = = (1.2.8)
X X
If the least significant digit (LSD) is the dth digit after the decimal point, then
the magnitude of the absolute error is not greater than half the value of LSD.
1
|ε x |=|X − x|≤ 10 −d (1.2.9)
2
If the number of significant digits is s, then the magnitude of the relative error
is not greater than half the relative value of LSD over MSD (most significant
digit).
|ε x | |X − x| 1 −s
|ρ x |= = ≤ 10 (1.2.10)
|X| |X| 2
1.2.4 Error Propagation
In this section we will see how the errors of two numbers, x and y, are propagated
with the four arithmetic operations. Error propagation means that the errors in the
input numbers of a process or an operation cause the errors in the output numbers.
Let their absolute errors be ε x and ε y , respectively. Then the magnitudes of
the absolute/relative errors in the sum and difference are
ε x±y = (X ± Y) − (x ± y) = (X − x) ± (Y − y) = ε x ± ε y
|ε x±y |≤|ε x |+ |ε y | (1.2.11)
|ε x±y | |X||ε x /X|+ |Y||ε y /Y| |X||ρ x |+ |Y||ρ y |
|ρ x±y |= ≤ = (1.2.12)
|X ± Y| |X ± Y| |X ± Y|