Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Boost used to have a minimax approximation algorithm in its codebase. Unfortunately, nobody knows enough about how it works it to maintain it, and you have to look in much older releases of Boost to get it.


This one? #include <boost/math/tools/remez.hpp>

I used some bits from it to help me in building my own log approximation but I didn't have time to dig into it.

I ended up doing Chebyshev approximation over [1, 2) interval but I extended the interval slightly to make sure that an error term at 1.0 is minimal (you can also minimise an error term at 2.0 if you want some smoothness between [1, 2) and [2, 4) intervals).

It's easy to calculate new interval values for Chebyshev approximation and it shouldn't be a problem to modify Remez but I couldn't find any Remez implementation that would let me do what I needed.

Usually, interval ends in Remez algorithm are fixed, while internal points can be moved by the algorithm. I needed a way to to fix one or two internal points (1.0 and optionally 2.0) but let the algorithm move interval ends within certian limits.

If anyone knows of any tool that let me do it, I'd be happy to play with it and publish my code. My approach is a bit similar to [1] but I'd more likely use Intel assembly or DynASM.

[1] http://gallium.inria.fr/blog/fast-vectorizable-math-approx/

PS The author of [1] uses remez from e Sollya tool but it doesn't let me fix internal points. I looked at the implementation but it's more obscure than boost/remez.

UPDATE: it's not clear from the above what my objectives were. I wanted to to produce exact values for integer powers of 2 including log2(1). This approach also gives a small relative error around x=1.


Yes, that one. It comes with a driver program using the Boost.Test framework that allows you to change the range and fix the values at the interval ends if that is an objective.

Their framework does not allow you to arbitrarily fix internal values, as per your spec however.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: