UTK - Math 171 - Alexiades

            Floating Point Numbers - Roundoff

Machine numbers

  • There are finitely many floating point numbers on any computer.
  • They are NOT evenly spaced (same # between consecutive powers of 2) so spread out further and further apart.
  • Any given real number x must be approximated by a nearest machine number, fl(x), resulting in a roundoff error.
    Important consequencies:
    1. There is an inherent error in representing real numbers, called round-off.
    2. Machine arithmetic is not necessarily commutative, i.e. the order of operations may affect the result!
    3. Loss of significant digits in arithmetic, especially in:
      • subtractive cancellation: when subtracting nearly equal reals
      • unbalanced multiplication: when nultiplying by a very small number (or dividing by a very large number).
    4. Number of decimal digits that can be trusted:   7 in single precision, 15 in double precision.

    Machine epsilon ε
  • ε is the smallest positive number such that 1+ε > 1
  • ε = 2−p , p=precision = # of bits in mantissa.
  • In 32 bit double precision, p=52, so   ε = 2−52 ≈ 10−15
  • For any real x,   fl(x) = x ( 1 + ε ), so   ε = ( fl(x) − x ) / x = relative error in representing x by fl(x)
  • Thus, the absolute error in representing x by fl(x) is   roundoff = fl(x)−x = εx , so it is proportional to x .
      So, the larger the number the larger the roundoff error!
  • In Matlab: eps(x) gives the machine number nearest to x for that computer.
              eps(1)   or just eps gives ε itself.
  • For example: eps(1) = 2.2204e-16 , eps(100) = 1.4211e-14 , eps(1000) = 1.1369e-13 , eps(1.e6) = 1.1642e-10 , ...
                losing more and more accuracy...
  • For example: 1+eps == 1 gives false,   1+eps/2 == 1 gives true
                So, any (positive) number less than ε is effectively zero in computation!