"how numbers are stored in computers"
This theorem shows that the Kahan summation algorithm computes a sum with significantly less rounding error than naïve summation. Specifically, each term
In naïve summation, small rounding errors pile up. Worst case, early terms like
For each term
Even though each operation introduces rounding error, the algorithm systematically cancels much of it out. It turns out that the distortion for each term
Kahan summation doesn't eliminate rounding error, but it controls it very effectively. Instead of errors accumulating linearly with the number of terms
Suppose a sum
Then the computed sum
In naive summation, define:
Then the computed sum is:
This leads to large coefficients of rounding error on early terms (e.g.
Here,
First Iteration (k = 1)
We compute:
Call the coefficients of
Recurrence Relations
By ignoring higher-order
From these, it can be shown:
Let
So the coefficient of
Hence, the total error is bounded by: