uxarray.utils.computing.two_sum

Contents

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_sum captures that rounding error in the companion term e so that s + e equals the true sum with no information lost. The cost is four extra floating-point operations beyond the addition itself.

Parameters:
  • a (float) – Input values.

  • b (float) – Input values.

Returns:

  • s (float) – Rounded sum fl(a + b).

  • e (float) – Rounding error term; s + e = a + b exactly.