Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition and subtraction #60

Closed
EricDarve opened this issue May 9, 2020 · 1 comment
Closed

Addition and subtraction #60

EricDarve opened this issue May 9, 2020 · 1 comment

Comments

@EricDarve
Copy link

* Addition and subtraction are dangerous, because when numbers of different magnitudes are involved,

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
Copy link
Owner

brazzy commented May 21, 2020

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!

@brazzy brazzy closed this as completed May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants