ERRORS AND NORMS
Avoiding Round-off Error: How to avoid these errors
Consider the summation
(1)
πβ
=β
ββ²β³nβ
=β
0(1)/(4n)β
=β
1β
+β
(1)/(4)β
+β
(1)/(16)β
+β
(1)/(64)β
+β
β
...
If the sum is computed backwards (n decreasing) then the sum grows gradually without mixing large and small errors.
Rewrite troublesome functions such as
(2)
(d)/(dx)lnxβ
=β
(1)/(x)β(d)/(dx)(f(x))β
=β
β
limΞxβ
ββ
0((f(xβ
+β
Ξx)β
ββ
f(x)))/(Ξx)
so that Ξx gets smaller by a magnitude each time it is called.
For logicals, use a tolerance rather than an exact number. Consider the use of this tolerance to check for three significant digit accuracy:
PROGRAM sum2 IMPLICIT NONE REAL :: ans INTEGER :: i ans = 0.0 DO i=1,10000 ans=ans+.0001 END DO WRITE(6,β(F15.8)β) ans β tol = 0.0001 IF (abs(ans-1.0) <= tol) THEN WRITE(6,*) βGood to go!β ELSE WRITE(6,*) βYikes!β ENDIF END PROGRAM sum2
NORMS
The definition of an error is eΜβ
=β
xβ
ββ
xΜ where eΜ is the error x is the actual value and xΜ is the computed value. Another value used to measure error is called the residual, defined as rΜβ
=β
Axβ
ββ
AxΜ. Given the following:
1.01x1β
+β
.99x2β
=β
2
β
.99x1β
+β
1.01x2β
=β
2
β
*.5cmx1β
=β
x2β
=β
1.0
β
If xΜβ
=β
β§β¨β©
1.01
β
1.01
β«β¬β eΜβ
=β
β§β¨β©
β
ββ
.01
β
β
ββ
.01
β«β¬β rΜβ
=β
β§β¨β©
β
ββ
.02
β
β
ββ
.02
β«β¬β β
Small Error
β
Small Residual
If xΜβ
=β
β§β¨β©
2.0
β
0.0
β«β¬β eΜβ
=β
β§β¨β©
1.0
β
β
ββ
1.0
β«β¬β rΜβ
=β
β§β¨β©
β
ββ
.02
β
.02
β«β¬β β
Large Error
β
Small Residual
||aΜ||ββ
=β
max |ai| iβ
=β
1,β
...,β
n
β
β
β
(||xβ
ββ
xΜ||β)/(||x||β)β
<β
tolerance
This is a relative approach to measure how accurate is a solution. The tolerance can vary, but the value should be a small number (tolerance). However, if the tolerance value is below the accuracy of computer or the algorithm, then it may never be achieved.
There are several different definitions of the norm of an array, the most useful of which are L2 and L:
L2 norm ||aΜ||2β
=β
β(|a|2β
+β
|ai|2β
+β
...β
+β
|an|2)
β
β
β
β
L norm ||aΜ||β
=β
nβ²β³iβ
=β
1|ai|
Next Page →
Next Page →
← Previous Page
← Previous Page