请解释 What Every Computer Scientist Should Know About Floating-Point Arithmetic 中的定理 4

Please explain Theorem 4 in What Every Computer Scientist Should Know About Floating-Point Arithmetic

我正在阅读 What Every Computer Scientist Should Know About Floating-Point Arithmetic。而且我发现了一个有趣的定理:(如果你已经看过这篇文章,可以跳到最后一段。)


定理4

如果使用以下公式计算 ln(1 + x):

当 0 ≤ x < 3/4 时,相对误差最大为 5ε,前提是用保护数字执行减法,e < 0.1,并且 ln 计算在 1/2 ulp 以内。

此公式适用于 x 的任何值,但仅对 x << 1 有意义,这是天真的公式 ln(1 + x) 中发生灾难性抵消的地方。虽然这个公式看起来很神秘,但它的工作原理有一个简单的解释。将 ln(1 + x) 写为

左边的因子可以精确计算出来,但是右边的因子µ(x) = ln(1 + x)/x在x加1的时候会有很大的舍入误差。然而,µ 几乎是常数,因为 ln(1 + x) ≈ x。所以稍微改变 x 不会引入太多错误。换句话说,如果 x̄ ≈ x,计算 xμ(x̄) 将是 xµ(x) = ln(1 + x) 的一个很好的近似值。是否存在可以准确计算出 x̄ 和 x̄ + 1 的 x̄ 值?有;即 x̄ = (1 x) 1, because then 1 + x̄ is exactly equal to 1 x.


按照作者的说法,1 + x̄正好等于1 x. This confused me: When x is very small, adding x to 1 should cause the loss of the information in the low order bits of x. Also, there will be a catastrophic cancellation in (1 x) 1,这会导致很多准确的数字消失

所以请告诉我,为什么 1 + x̄ 正好 等于 1 x 在这个定理中?

你必须re-read x̄ 和 . x̄ is a value near x which has no low bits to lose. Therefore, 1+x̄ is exact, and the same as the rounded result 1x

的定义