Understanding ulps in catastrophic cancellation

399 views Asked by At

I'm reading what every computer scientist should know about floating point and I don't understand the following statement:

Catastrophic cancellation occurs when the operands are subject to rounding errors. For example in the quadratic formula, the expression b2 - 4ac occurs. The quantities b2 and 4ac are subject to rounding errors since they are the results of floating-point multiplications. Suppose that they are rounded to the nearest floating-point number, and so are accurate to within .5 ulp. When they are subtracted, cancellation can cause many of the accurate digits to disappear, leaving behind mainly digits contaminated by rounding error. Hence the difference might have an error of many ulps. For example, consider b = 3.34, a = 1.22, and c = 2.28. The exact value of b2 - 4ac is .0292. But b2 rounds to 11.2 and 4ac rounds to 11.1, hence the final answer is .1 which is an error by 70 ulps, even though 11.2 - 11.1 is exactly equal to .1. The subtraction did not introduce any error, but rather exposed the error introduced in the earlier multiplications.

From what I've read, ulps are units in the last place so if I round 11.1556 with 11.2 I can have a maximum of 0.5 units in the last place, i.e. a maximum of 0.05 of error.

But why if I get 11.2 - 11.1 = 0.1, this is a 70 ulps error?? I would have thought this last value is an error of 0.7 ulps

1

There are 1 answers

0
coproc On BEST ANSWER

If you relate the error 0.1 - 0.0292 = 0.0708 to the ulp of the exact result (0.0001), the error is even 708 ulps. The original version contained a typo here (see footnote 6 in your reference).