Stupid is as Stupid Does: Taking the Square Root of the Square of a Floating-Point Number
Author(s) -
Sylvie Boldo
Publication year - 2015
Publication title -
electronic notes in theoretical computer science
Language(s) - English
Resource type - Journals
SCImago Journal Rank - 0.242
H-Index - 60
ISSN - 1571-0661
DOI - 10.1016/j.entcs.2015.10.004
Subject(s) - square root , square (algebra) , floating point , mathematics , point (geometry) , arithmetic , computation , exponent , proof assistant , root (linguistics) , range (aeronautics) , square number , discrete mathematics , interval (graph theory) , algorithm , combinatorics , mathematical proof , geometry , philosophy , linguistics , materials science , composite material
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/(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
Accelerating Research
Robert Robinson Avenue,
Oxford Science Park, Oxford
OX4 4GP, United Kingdom
Address
John Eccles HouseRobert Robinson Avenue,
Oxford Science Park, Oxford
OX4 4GP, United Kingdom