Remez tutorial 5/5: additional tips

This part of the tutorial is constantly updated. Check its history to know what is new.

What to do when the solver doesn’t converge?

It may happen that the solver doesn’t converge. There are many possible reasons for that:

  • the function being approximated is not smooth enough; try to increase the polynomial degree, or reduce the approximation range.
  • the solver cycles between a finite number (usually 3 or 4) of solutions; in this case, experiments indicate that you may safely choose the solution with the smaller error.

Floating point precision

The Remez algorithm performs high precision computations to find its solutions. As a result, the polynomial coefficients found are printed with far more decimals than the usual double or float numbers can store. So when you write:

float a = 8.333017134192478312472752663154642556843e-3;

The exact value of a is actually:

8.333017118275165557861328125e-3
         ^-- this decimal changes!

See “fixing lower-order parameters” for both an explanation of why this can be a problem, and a method to reduce the introduced error.

When not to use Remez?

There are cases when you should expect the Remez algorithm to potentially perform badly:

There are cases where you should not try to use the Remez algorithm at all:

  • when the source range is not finite, eg. [0,+∞]
  • when the destination range is not finite, eg. log(x) tends to -∞ near 0
  • when the function to approximate has an infinite derivative at a point contained in or near the approximation range, eg. sqrt(x) or cbrt(x) in 0

What if I want to use Remez anyway?

If you need to approximate a function f(x) over [a,+∞] and for some reason you want to use the Remez exchange algorithm, you can still through a change of variable: y = 1/x. The function to approximate becomes f(1/y) and the new range is [0,1/a] (see “changing variables” for how to deal with 1/x in 0). The minimax polynomial will use 1/x as its variable; please be aware that computing 1/x at runtime may be expensive.

Conclusion

Please report any trouble you may have had with this document to sam@hocevar.net. You may then return to the Remez exchange documentation.

Last modified 6 years ago Last modified on Feb 13, 2012, 8:46:26 PM