You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Very cool library! I found it mentioned in a constexpr stackexchange question. I like to dabble with low level math like this and I've derived a theoretically exact way to calculate sine/cosine by playing games with the half-angle formulae and bits. I've provided the derivation and a (probably poorly written) C++14 constexpr version (requires constexpr abs, sqrt, sgn, and modf). You might already know this trickery. I can't promise the C++14 version is correct (Clang 6 is happy with it) or if MSVC will tolerate it.
I'm not suggesting you use this. Your implementation using Taylor series (if I'm not mistaken) is probably a lot faster since this formulation needs to examine at most the number of mantissa bits (e.g. 52 for double precision)!
I think there is a name for this method. I don't remember off the top of my head. But good fun!
Thanks for the library!
Here's the demo code... I can just use your static math library from now on! demo.txt
And below are notes I wrote myself if I ever look at this code again in the distant future.
NOTE: I didn't intend for the LaTeX pictures to automatically display.
Explanation
Pseudo Code
The text was updated successfully, but these errors were encountered:
Indeed, it's only exact on paper. But it's exact on paper for finitely represented binary numbers using a finite number of operations. Contrast this with infinite series that need infinite terms to be exact on paper.
This kind of algorithm is seemingly related to CORDIC algorithms (that's the name I couldn't remember), although my derivation is different than CORDIC described on Wikipedia. That one appears to produce 1 bit of the output per iteration which I think is far more interesting than what I've derived.
Monthly reminder that this library was a toy project and that I know next to nothing to floating point math internals and non-trivial math in general. The exponential, logarithmic, trigonometric and hyperbolic functions have been contributed by other people who are more knowledgeable in those areas than I am :p
Algorithms with fewer rounding errors do sound interesting but I am hardly in a position to judge what is actually better.
Very cool library! I found it mentioned in a constexpr stackexchange question. I like to dabble with low level math like this and I've derived a theoretically exact way to calculate sine/cosine by playing games with the half-angle formulae and bits. I've provided the derivation and a (probably poorly written) C++14 constexpr version (requires constexpr abs, sqrt, sgn, and modf). You might already know this trickery. I can't promise the C++14 version is correct (Clang 6 is happy with it) or if MSVC will tolerate it.
I'm not suggesting you use this. Your implementation using Taylor series (if I'm not mistaken) is probably a lot faster since this formulation needs to examine at most the number of mantissa bits (e.g. 52 for double precision)!
I think there is a name for this method. I don't remember off the top of my head. But good fun!
Thanks for the library!
Here's the demo code... I can just use your static math library from now on!
demo.txt
And below are notes I wrote myself if I ever look at this code again in the distant future.
NOTE: I didn't intend for the LaTeX pictures to automatically display.
Explanation
Pseudo Code
The text was updated successfully, but these errors were encountered: