Pairwise summation keeps the rounding error of a sum small
On uniform numbers pairwise summation errs by under , left to right by about .
left to rightpairwise
| Quantity | Viv | Checked by |
|---|---|---|
err left to right | 49.9961 | left-to-right summation errs by more than 20 u times the sum of |t| |
err pairwise | 0 | pairwise summation errs by less than 5 u times the sum of |t| |
summation_order.viv
Output · native build · Oct 14, 2026 · 0.89 s
err_left_to_right: 49.9961 err_pairwise: 0
- ✓ pairwise summation errs by less than 5 u times the sum of |t|
- ✓ left-to-right summation errs by more than 20 u times the sum of |t|
Open in the workbenchAtlasMore math claims
- Full statement
- Adding 1,048,576 random numbers drawn uniformly from the unit interval in double precision, pairwise summation (blocks of 8 added in a tree) leaves an error below 5 units of roundoff times the sum of the magnitudes, while adding left to right leaves an error above 20 such units. The worst-case bounds behind the gap are about for left to right and about for pairwise.
- Scope
- One seed and one distribution (uniform, all terms positive, so is the sum). Observed errors sit far below the worst-case bounds; the claim is about the observed sizes at this n. Sums whose terms cancel lose relative accuracy for both orders.
- Reference
- fsum (exactly rounded summation, the algorithm of Python's math.fsum) for the true sum; Higham, Accuracy and Stability of Numerical Algorithms (2nd ed., 2002), section 4.2, for the bounds and per unit of .
claims/math/summation_order.viv#dfff524788