4 ms·
Some trivia, partly stolen from Bruce Dawson[0]: The sin(x) = x approximation is actually exact (in terms of doubles) for |x| < 2^-26 = 1.4e-8. See also [1]. T
by MauranKilom 5y ago
Some trivia, partly stolen from Bruce Dawson[0]:
The sin(x) = x approximation is actually exact (in terms of doubles) for |x| < 2^-26 = 1.4e-8. See also [1]. This happens to cover 48.6% of all doubles.
Similarly, cos(x) = 1 for |x| < 2^-27 = 7.45e-9 (see [2]).
Finally, sin(double(pi)) tells you the error in double(pi) - that is, how far the double representation of pi is away from the "real", mathematical pi [3].
[0]: https://randomascii.wordpress.com/2014/10/09/intel-underestimates-error-bounds-by-1-3-quintillion/ https://randomascii.wordpress.com/2014/10/09/intel-underesti...
[1]: https://github.com/lattera/glibc/blob/master/sysdeps/ieee754/dbl-64/s_sin.c#L216 https://github.com/lattera/glibc/blob/master/sysdeps/ieee754...
[2]: https://github.com/lattera/glibc/blob/master/sysdeps/ieee754/dbl-64/s_sin.c#L282 https://github.com/lattera/glibc/blob/master/sysdeps/ieee754...
[3]: https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ https://randomascii.wordpress.com/2012/02/25/comparing-float...