Kahan summation and relative errors; or real life stories about "getting the wrong result instead of the right one"

I'm interested in "war stories" like this:

  • I wrote a program involving the sum of floating point numbers, but I did not use Kahan sum.

  • The amount was bad_sum

    , and the program gave me the wrong result.

  • A colleague of mine who is more versed in numerical analysis than I looked at the code and suggested that I use Kahan summation, now the sum good_sum

    , and the program gives me the correct result.

I'm interested in actual production code, not code samples "artificially" created to explain Kahan's summation algorithm.

Specifically, what's the relative error (bad_sum-good_sum)/good_sum

for your application?

Until now, I do not have a similar story. Maybe I'll do some tests (by running my program on the input dataset, running the program results and sums with and without Kahan, estimate the relative error).

+3


source to share





All Articles