Compensated summation retains a correction for low-order information lost to roundoff error in successive floating-point arithmetic additions. Kahan summation is a common implementation; it can substantially reduce accumulated error when many terms are added.
The Kahan summation algorithm computes a sum in floating-point arithmetic while carrying a correction for low-order information lost by successive additions. With accumulator and correction initially zero, process each input in this order:Every operation shown is rounded in the working floating-point representation. The new approximates the portion added too much or too little in the rounded , so the next input subtracts it. For binary64 inputs in that order, ordinary left-to-right summation loses both small increments, returning one; this algorithm recovers .
y = x - c
t = s + y
c = (t - s) - y
s = tThe correction substantially improves many long sums, but is not an exact summation method and does not remove ill-conditioning when large opposite-sign terms nearly cancel. Its operation order is essential: a compiler that rewrites as exact algebraic zero destroys the correction.[ref]
https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html. Goldberg, Errors in Summation and Optimizers: compensated summation and why reassociation invalidates it
Articles by others on the same topic
There are currently no matching articles.