Implementing Advanced Math Functions
spin.atomicobject.com
spin.atomicobject.com
Let's try this: Tell me how you would construct a minimax approximation according to your definition?
http://code.google.com/p/mpmath/source/browse/trunk/mpmath/l...
You really need to reduce the argument to a sane range, otherwise the `n' required even in infinite precision would be huge.
If someone is interested in how to do it, check out http://www.netlib.org/fdlibm/
And most of these are doing more than simply reducing N in range. They typically have a transform (or three) which maps N onto a function which is very close to linear, so they can use a 5-6 term polynomial approximation to get full precision across the whole range. It's all very clever, really.
But it's terribly documented (and, at this point, ruthlessly forked). I'm honestly shocked there hasn't been an effort made to clean this code up, put it into a single project and get all the divergent libm implementations using it.
[0]http://www.axiom-developer.org/ [1]http://www.axiom-developer.org/axiom-website/documentation.h...
If you're interested, I have the test code here: https://github.com/jeremysalwen/vectrig
float sin(float const x) {
float const y = (4 / pi) * x + (-4 / (pi * pi)) * x * abs(x);
return y + 0.218 * (y * abs(y) - y);
}