When Kahan summation still fails, and Neumaier's fix
Asked at HRT, Jump Trading
Classic Kahan summation cancels the drift when many small numbers pile onto a growing total. But feed it a big number, then a small one, then the big number's negative:
>>> kahan_sum([1e16, 1.0, -1e16])
0.0 # the 1.0 vanished; the true answer is 1.0
Explain why classic Kahan loses the 1.0 here, and implement a variant that returns 1.0.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.