Implementing Advanced Math Functions
spin.atomicobject.com
Implementing Advanced Math Functions
1–10 of 24 posts
Re: Implementing Advanced Math Functions
#2Re: Implementing Advanced Math Functions
#3Re: Implementing Advanced Math Functions
#4This article lacks a discussion about floating-point vs real arithmetic. Naively implementing these functions is bound to produce nasty rounding problems.
Re: Implementing Advanced Math Functions
#5This article lacks a discussion about floating-point vs real arithmetic. Naively implementing these functions is bound to produce nasty rounding problems.
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/
Re: Implementing Advanced Math Functions
#6Re: Implementing Advanced Math Functions
#7This is the type of stuff I come to HN for. This is so refreshing to see after days worth of press releases about Apple, new gadgets, and other mainstream news regurgitation.
[0]http://www.axiom-developer.org/ [1]http://www.axiom-developer.org/axiom-website/documentation.h...
Re: Implementing Advanced Math Functions
#8 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);
}Re: Implementing Advanced Math Functions
#9Unfortunately, Taylor series are just about the worst choice possible for implementing transcendental math functions, due to the highly non-uniform error distribution. You end up doing far to much work to get good accuracy near the edges of the domain of interest. Much better choices of polynomial approximations for almost any such situation are (in increasing order of goodness and difficulty to work with): Chebyshev…
Re: Implementing Advanced Math Functions
#10Unfortunately, Taylor series are just about the worst choice possible for implementing transcendental math functions, due to the highly non-uniform error distribution. You end up doing far to much work to get good accuracy near the edges of the domain of interest. Much better choices of polynomial approximations for almost any such situation are (in increasing order of goodness and difficulty to work with): Chebyshev…
If your goal is accuracy, you are absolutely correct. But in the instances where I've wanted to implement my own versions of transcendental math functions, accuracy was actually pretty low on my list of priorities. Often just a couple terms of a taylor series was accurate enough, fast, and easy to implement.