uxarray.utils.computing.two_sum#
- uxarray.utils.computing.two_sum(a, b)#
Knuth’s TwoSum: return (s, e) with s = fl(a + b) and s + e = a + b exactly.
Floating-point addition rounds the mathematical result to the nearest representable value.
two_sumcaptures that rounding error in the companion termeso thats + eequals the true sum with no information lost. The cost is four extra floating-point operations beyond the addition itself.- Parameters:
- Returns:
s (float) – Rounded sum fl(a + b).
e (float) – Rounding error term; s + e = a + b exactly.
References
Knuth, D. E. (1997). The Art of Computer Programming, Volume 2: Seminumerical Algorithms (3rd ed.). Addison-Wesley, Section 4.2.2, Theorem B.