Rounding errors

What floating-point computation does to results: absolute and relative error, machine epsilon, absorption, catastrophic cancellation, accumulation, comparing with a tolerance, and the difference from method error.

  • 26 cards
  • 5 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. The numbers
  5. Understand

A few cards from the deck

  • Rounding error: what is it?

    Show the answer

    The gap between a real number and its representation in the computer's finite format, or between the exact result of an operation and the one the machine stores.

    Each operation may add a small relative error (about 10⁻¹⁶ in double precision); it is their accumulation or amplification that does the damage.

  • What does this program print?

    ```python
    s = 0.0
    for _ in range(10):
    s += 0.1
    print(s == 1.0)
    print(s)
    `

    • False then 0.9999999999999999
    • True then 1.0, since ten times 0.1 is 1
    • False then 1.0000000000000002, rounded upward
    • False then 1.0, the display rounding the value
    Show the answer

    False then 0.9999999999999999

    0.1 has no finite binary expansion: each addition adds a small error, and ten additions give 0.9999999999999999. print shows enough digits to tell this number from 1.0.

  • When a very small number is added to a very large one, the small one can vanish: this is …. In double precision, 1e16 + 1 gives ….

    Show the answer

    When a very small number is added to a very large one, the small one can vanish: this is absorption. In double precision, 1e16 + 1 gives 1e16.

    Around 1e16, two consecutive floats are 2 apart: 1e16 + 1 falls between two floats and is rounded to 1e16. Hence 1e16 + 1 − 1e16 = 0.0, whereas 1e16 − 1e16 + 1 = 1.0.

  • Relative error: what is it?

    Show the answer

    The absolute error divided by the exact value, in absolute value: |x̃ − x|/|x|, often given as a percentage.

    One millimetre of error does not weigh the same on 10 mm and on 10 km. Relative error measures precision, absolute error only the gap.