了解灾难性取消中的 ulp

Understanding ulps in catastrophic cancellation

我正在阅读 what every computer scientist should know about floating point 但我不理解以下语句:

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.

根据我的阅读,ulps 是最后一位的单位,所以如果我将 11.1556 舍入为 11.2,我可以在最后一位最多有 0.5 个单位,即最大误差为 0.05。

但是为什么如果我得到 11.2 - 11.1 = 0.1,这是一个 70 ulps 的错误??我本以为最后一个值是 0.7 ulps

的误差

如果将错误 [​​=10=] 与确切结果 (0.0001) 的 ulp 相关联,错误甚至是 708 ulps。原始版本此处包含错字(参见 footnote 6 in your reference)。