Accumulating Small Terms Before Large Terms
Adding a very small term to a much larger accumulated result can round away the smaller contribution.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace an illustrative scale
In binary64, adding 1 to \(10^{16}\) can leave it unchanged. Adding together several ones first can create a representable change when combining later. See floating-point spacing.
Choose a summation rule from accuracy needs
Reordering can help in some distributions, while cancellation and signed values complicate a simple magnitude rule. Compensated summation retains an estimate of rounding drift inside the loop.[1][2]
Use representable values to exhibit order dependence
In binary64 round-to-nearest with ties to even, \(2^{53}+1\) rounds to \(2^{53}\). Adding a second one sequentially can repeat that loss. Combining the ones first produces two, and \(2^{53}+2\) is representable. See parallel floating-point reduction.
(((2^53)+1)+1) can give 2^53
((2^53)+(1+1)) gives 2^53+2
Exact total is 2^53+2
Evaluate the summation strategy against input patterns
Pairwise or compensated summation can reduce error under appropriate assumptions. Ordering small same-sign terms first helps in this case. Mixed signs and cancellation need their own checks against a trusted reference.