-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Robust bisect #15
Comments
The compilers do interpret the instructions differently. Question is whether the error of ADD+MUL is lower than the error of SUB + FMA, and whether it even matters for > FP32? (a + b)/2
|
We can compile the lib and tests using the |
In the Boost C++ root finding library ( delta = 0.5F * (guess - max); // lucky that 0.5F has an exact binary representation...
result = guess - delta; in the fallback bisection step of Newton's method. However in the actual bisection routine they do it the "naive" way: while(count && (0 == tol(min, max)))
{
T mid = (min + max) / 2; // 2 gets correctly cast to the required precision
T fmid = f(mid);
... So it looks like they are indifferent to this issue. In SciPy's zero methods (only double precision, e.g. https://github.com/scipy/scipy/blob/v1.9.0/scipy/optimize/Zeros/bisect.c) they use the "correction" approach consistently in all of the solvers: dm = xb - xa;
solver_stats->iterations = 0;
for (i=0; i<iter; i++) {
solver_stats->iterations++;
dm *= .5; // only double supported anyways, else should be (T) 0.5;
xm = xa + dm; |
The following paper is dedicated entirely to bisecting an interval:
A preprint is available here. |
roots-fortran/src/root_module.F90
Line 2524 in 60524bc
The excerpt below is taken from Kahaner, Moler, & Nash, Numerical Methods and Software, 1989, Prentice-Hall, Inc.:
According to Herbie this rearrangement seems irrelevant in FP64, however I couldn't find an option to see what happens in lower precision: https://herbie.uwplse.org/demo/ebc6120a0224e43ec4e96ae4c79d8bf1537cfdf8.1.6/graph.html#history
The text was updated successfully, but these errors were encountered: