News for hackers. Stuff that matters.

alexSanchStern

Re:Improving Floating Point Accuracy: A Look at Sums on Monday October 19, 2015 @02:39PM (#10414704)
Even when summing using doubles, you can lose precision. In general, Kahan summation allows you to double the intermediary precision of your sums, so if you're losing precision even with 64-bit doubles, Kahan summation can give you 128-bits of intermediary precision, without going to software floating point solutions.
Re:Improving Floating Point Accuracy: A Look at Sums on Monday October 19, 2015 @02:32PM (#10414661)
Pairwise summation is definitely a useful technique, depending on your situation. However, it does have the key limitation that you need to have all your data beforehand. There are quite a few cases in practice where you have streaming data, and Kahan summation handles this just fine. In addition, if your data is really unbalanced in it's magnitudes, pairwise summation can still lose a fair amount of precision compared to Kahan summation. There are definitely cases where you'd want to use one, and cases where you'd want to use the other.
Re:Improving Floating Point Accuracy: A Look at Sums on Monday October 19, 2015 @02:27PM (#10414639)
Yes, that's completely true. But while there are still inputs for which terrible accuracy could result, for many of the inputs which would arise in practice, the Kahan summation technique is "good enough" to prevent loss of accuracy. The chances of getting an input for which catastrophic cancellation would result on the doubled precision are far overshadowed by the chances of getting inputs for which the normal summation would have unacceptable loss accuracy, but Kahan summation would not.