|
|
|
|
|
by all-fakes
2185 days ago
|
|
I thought fast-math meant (among other things) that the compiler could algebraically simplify things using some rules for real numbers that don't apply to 32-/64-bit floating point numbers. I'd expect that reducing the number of operations would more often than not reduce the error due to rounding, which is what most people would want when they talk about "correctness". Which step in this (very naive) argument is wrong? |
|
1.23456789 - 1.23456788 = 0.00000001 = 1 * 10^-8
So here we’ve gone from 9 significant figures down to 1. This phenomenon will make a naïve Taylor series approximation of e^x be very inaccurate for negative x, due to the sign alternating between positive and negative on every term, causing a lot of catastrophic cancellation.
[1] https://en.wikipedia.org/wiki/Loss_of_significance