ERRORS AND NORMS

ERRORS AND NORMS

PRECISION ERROR
Consider the following code:
Program sum
     IMPLICIT NONE
     REAL :: ans
     INTEGER :: i
     ans = 0.0
     DO i=1,10000
          ans=ans+.0001
     END DO
     WRITE(6,’(F15.8)’) ans
     END PROGRAM sum
If one were to calculate this by hand, one would come to the conclusion that ans=1.000. However, running the code inevitably yields some answer that is close to one but would read ans=.99935269 or 1.00005352 or a similar answer within a couple thousandths of the “exact” answer. This error is the result of computer precision. Computers operate on the binary system, which carries with it some precision errors. Every binary digit (bit) has ’0’ or ’1’ as its options.
[Decimal Base 10] 110.11  =  (1*102) + (1*101) +  (0*100) + (1*10 −1 ) + (1*10 −2 )  =   one hundred ten and eleven hundredths
[Binary Base 2] 110.11  =  (1*22) + (1*22) + (0*20) + (1*2 −1 ) + (1*2 −2 )  =  4 + 2 + 0 + (1)/(2) + (1)/(4)  =  6.75  =   [six and seventy-five hundredths]
Above the difference between the meaning of a base ten number identified as 110.11 and a binary number identified by 110.11.is readily apparent.
Consider a 32-bit word (single precision) of Integer then Floating Point types:
[Integer] (1*230) + ... + (1*20) = 2, 147, 483, 647
0 1111111111111111111111111111111
sign (1 position) number (31 Positions)

FLOATING POINT ERROR
0 1111111 111111111111111111111111
sign (1 position) Power (7 Positions) Mantissa (Fraction) (24 Positions)
The floating point syntax is best explained with the following example turning 3.5 to a binary floating point number.
3.5  →  11.1  →  .111*22  →  0 0000010 111000000000000000000000
decimal Binary Binary sign exponent (2) A Binary Decimal
Fraction (+) Value (.111)
ROUND-OFF ERROR
From the sample program, although the answer given has 7 digits, there is only 3 digit accuracy:
.999|3526
Everything after the bar is round-off error resulting from floating point arithmatic and binary representations. Numbers contain more bits than can be stored in the 24 bit mantissa, so they are rounded off.

Types of Round-off Errors

  1. Add or subtract one large + one small number
  2. Subtracting two almost equal numbers
  3. Overflow and underflow errors:
    Numbers are two large or small for definition of a word
    Division by a very small number (divide check)
    Underflow is not as serious ("machine zero" sets number to 0)
  4. Division by a small number may not lead to overflow, but it can lead to round-off errors
  5. Multiplication or division may result in a repeating Decimal
  6. Quantifying errors such as logical statements require an exact #
    IF (x .== 1.0)  x=y/z
    
Next Page →
Next Page →