### Slightly simplify initial bisection interval algorithm

parent 54d820b7
Pipeline #8763 passed with stage
in 3 minutes and 37 seconds
 ... ... @@ -911,30 +911,30 @@ int main (int argc, char *argv[]) try } // If the domain contains 1, try to find a better initial interval guess. // Otherwise use domain as initial guess. // Otherwise stay with the domain as initial guess. if (contains(I, 1)) { // Start from z=1 and successively double the value of z // until we have found f(z)>=0 for using z as upper bound. // While doing so, replace the lower bound by z whenever // f(z)<0. In the special case f(z)=0, we're done and // can instantly return the root z. double z = 1; double fz = f(z); while(fz < 0) // Start from I=1 and successively double the step length // until we have found an upper bound with f(I)>0. // While doing so, replace the lower bound I by I // whenever f(I)<0. That way I will always be a lower // bound with f(I)<0. // In the special case f(I)=0, we're done and can instantly // return the found root I. I = 1; fI = f(I); while(fI < 0) { I = z; fI = fz; z = dom.projectIn(z*2); fz = f(z); I = I; fI = fI; I = dom.projectIn(I*2); fI = f(I); } if (fz == 0) if (fI == 0) { xi = z; xi = I; return; } I = z; fI = fz; } else fI = f(I); ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment