-
Notifications
You must be signed in to change notification settings - Fork 37
Tutorial 5 of 5: additional tips
This part of the tutorial is constantly updated. Check its [?action=history history] to know what is new.
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.
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.
There are cases when you should expect the Remez algorithm to potentially perform badly:
- when the function is not continuous (for instance, a step function)
- when the function is not differentiable (for instance, the x+abs(x) function)
- sometimes when the function is not smooth
- sometimes even when the function is not analytic
There are cases where you should not try to use the Remez algorithm at all:
- when the source range is not finite, e.g. [0,+∞]
- when the destination range is not finite, e.g. 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, e.g. sqrt(x) or cbrt(x) in 0
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.
Please report any trouble you may have had with this document to [email protected]. You may then return to the [wiki:doc/maths/remez Remez exchange documentation].