IEEE double 满足 sqrt(x*x) ≠ x

IEEE double such that sqrt(x*x) ≠ x

在计算x*x不上溢或下溢到Inf、[=14的情况下,是否存在IEEE双精度x>0使得sqrt(x*x) ≠ x =],还是非正规数?

假设 sqrt returns 是最接近的可表示结果,x*x 也是如此(两者均由 IEEE 标准规定,"square root operation be calculated as if in infinite precision, and then rounded to one of the two nearest floating-point numbers of the specified precision that surround the infinitely precise result")。

假设如果存在这样的双打,那么可能有接近1的例子,我写了一个程序来寻找这些反例,但没有找到1.0和[=18=之间的任何一个].

之前的类似问题 perfect squares and floating point numbersx*x 的计算 涉及舍入的情况给出了否定的回答。这个答案对于这个问题是不够的,因为 x*x 可能涉及一个方向的舍入,然后 sqrt(x*x) 可能涉及 相同 方向的舍入,因此产生的答案不完全是 x.

Sylvie Boldo 认为 formally proved 满足您问题条件的 floating-point 号码不存在。

引用文章摘要:

Floating-point experts know that mathematical formulas may fail or give imprecise results when implemented in floating-point arithmetic. This article describes an example where, surprisingly, it is absolutely not the case. Indeed, using radix 2 and an unbounded exponent range, the computation of the square root of the square of a floating-point number a is exactly |a|. A consequence is the fact that the floating-point computation of a/ sqrt (a2 + b2) is always in the interval [−1, 1]. This removes the need for a test when calling an arccos or an arcsin on this value. For more guarantees, this property was formally checked using the Coq proof assistant and the Flocq library. The conclusion will give hints on what happens without assumptions and in other radices, where the behavior is very different.

“使用基数 2”可能隐含在您的问题中(尽管 IEEE 也标准化了十进制 floating-point 数字格式和操作),并且“无限指数范围”相当于您的“无溢出或下溢”限制。

使 属性 成为可能的一个原因是 x*x 在某种程度上“扩展”(例如,区间 [1,2] 映射到 [1,4])这样,当没有上溢或下溢时,* 可能发生的舍入是良性的,并且 x 仍然是最接近 floating-point 的可表示数字 floating-point 产品 x*x。这个 hand-wavy 论点不构成证明,所以上面链接的文章包含一个证明是件好事。