brazzy / floating-point-gui.de

Website that provides concise answers to common questions about floating-point numbers.
http://floating-point-gui.de/
1.01k stars 166 forks source link

Addition and subtraction #60

Closed EricDarve closed 4 years ago

EricDarve commented 4 years ago

https://github.com/brazzy/floating-point-gui.de/blob/3d2c97d03f5f026e1862be30053128bb2d3873d3/content/errors/propagation.html#L13

I don't think this line really represents what is happening. The typical problem is trying to subtract 2 numbers that are almost equal. An example is computing (exp(eps) - 1) / eps. For a small eps, exp(eps) - 1 may be computed with insufficient accuracy and the final result is typically inaccurate. Adding/subtracting numbers that have different magnitudes typically does not lead to issues in a computation. See "Catastrophic cancellation" in your reference https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

brazzy commented 4 years ago

The problem I had in mind was the one solved by Kahan summation. But catastrophic cancellation is of course also important and not addressed by the line you cited. I have expanded this line to explain and give examples for both issues.

Thanks for bringing this to my attention!