Welcome to AE Resources
ERRORS AND NORMS

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
The opposite can also be shown. Consider an array with n elements. The norm can be computed as
||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