Numerical precision

@F-YF posted an ill-conditioned sum whose terms (in exact arithmetic) should exactly cancel to give zero. Any roundoff error can give a nonzero answer, which is an infinite relative error compared to 0.0 (no digits are correct), no matter how much precision you have.

(From another perspective, compared to the magnitude of the summand terms \sim 1/x^6 \approx 10^{58}, an error of 10^{43} is quite small: 10^{43} / 10^{58} = 10^{-15}.)

This is exactly the same as the issue discussed in another thread here: "sum([1.0, 1e100, 1.0, -1e100])" fails - #10 by stevengj

2 Likes