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

那年仲夏 提交于 2019-12-01 03:00:26

Sylvie Boldo has formally proved that a floating-point number satisfying the conditions in your question does not exist.

Quoting the abstract of the article:

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.

“using radix 2” was likely implicit in your question (although the IEEE has also standardized decimal floating-point number formats and operations), and “an unbounded exponent range” is equivalent to your “no overflow or underflow” restriction.

A reason making the property possible at all is that x*x “expands” (the interval [1,2] is mapped to [1,4], for instance) in a way such that, when there is no overflow or underflow, the rounding that can happen for * is benign and x is still the closest representable floating-point number to the real square root of the floating-point product x*x. This hand-wavy argument does not constitute a proof, so it's a good thing that the article linked above contains one.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!