3 ms·
> 5 ULPs is a bug or a garbage library. I wouldn't say that. There is definitely a trade-off between accuracy and speed, and that trade-off varies for differen
by jcranmer 7y ago
> 5 ULPs is a bug or a garbage library.
I wouldn't say that. There is definitely a trade-off between accuracy and speed, and that trade-off varies for different mathematical functions. And it's not unreasonable for some people to say "I can tolerate losing 10 ULPs if it means the code will run twice as fast." None of the current math library implementations do a good job of letting users explore those trade-offs, and many of them don't even bother to give a claimed accuracy result.
(Note that Sun's [1] java.lang.Math does give ULP requirements on math functions, and Math.tanh has a 2.5 ULP accuracy requirement--atan2, sinh, cost, and tanh are the only functions with a >1 ULP accuracy bound).
[1] And yes, I'm calling out Sun here and not Oracle, because it was Sun who designed the math library and reported the error bounds, and the standard math library that people use when they're not shelling out to libm is Sun's fdlibm implementation anyways.