I have been looking for a Julia equivalent of Python’s
fsum and have thus far been unable to find one. Is there an implementation already available? If not I will write my own and put it on Github for others to use.
From the Python docs:
math.fsum ( iterable )
Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:
The algorithm’s accuracy depends on IEEE-754 arithmetic guarantees and the typical case where the rounding mode is half-even. On some non-Windows builds, the underlying C library uses extended precision addition and may occasionally double-round an intermediate sum causing it to be off in its least significant bit.
For further discussion and two alternative approaches, see the ASPN cookbook recipes for accurate floating point summation.