-
Notifications
You must be signed in to change notification settings - Fork 36
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+|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,+\infty]$ - when the destination range is not finite, e.g.
$\log(x)$ tends to$-\infty$ 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$\sqrt[3]{x}$ in 0
If you need to approximate a function
Please report any trouble you may have had with this document to sam@hocevar.net. You may then return to the [wiki:doc/maths/remez Remez exchange documentation].