
Approximating the Sine Function with Quadratics - squeakynick
http://datagenetics.com/blog/july12019/index.html
======
olliej
Nit: modern computers don’t have efficient trig functions anymore - my
understanding is that the complexity is so high that the overhead of
instruction dispatch isn’t significant (which is a big part of the cost for
things like sqrt).

It is true that chips do have them: x87 hardware is still present on x86
hardware, even in 64 bit. But x87 is essentially considered completely legacy
(Windows-64bit doesn’t use it for long double) - no meaningful perf changes in
a decade or more (beyond clock improvements I assume)

Then loading the values takes a while as you have to load them onto the x87
stack, which requires conversion to the x87 ieee formats (it is ieee just
different bit sizes), which isn’t cheap.

And that gets you all the way to being able to use: fcos, fsin, fsincos, ftan,
fatan, fexp, fexpm1, and a few other transcendental functions (there’s also
fprem and fprem1, two slightly different floating point partial remainder
functions)

After you’ve run those instructions, you then have to copy them off the x87
stack, which is also only through memory.

What do you have at that point? Incorrect values. Why? Because the algorithms
used in the x87 unit weren’t as accurate as they were thought to be, but by
that point intel realized that continuing to invest in x87 was no in anyone’s
interest - using SSE directly was already faster, and accuracy could be
corrected without changing hardware.

