Commit 9b8a756a authored by Gräser, Carsten's avatar Gräser, Carsten
Browse files

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]=1 and successively double the step length
// until we have found an upper bound with f(I[1])>0.
// While doing so, replace the lower bound I[0] by I[1]
// whenever f(I[1])<0. That way I[0] will always be a lower
// bound with f(I[0])<0.
// In the special case f(I[1])=0, we're done and can instantly
// return the found root I[1].
I[1] = 1;
fI[1] = f(I[1]);
while(fI[1] < 0)
{
I[0] = z;
fI[0] = fz;
z = dom.projectIn(z*2);
fz = f(z);
I[0] = I[1];
fI[0] = fI[1];
I[1] = dom.projectIn(I[1]*2);
fI[1] = f(I[1]);
}
if (fz == 0)
if (fI[1] == 0)
{
xi = z;
xi = I[1];
return;
}
I[1] = z;
fI[1] = fz;
}
else
fI[1] = f(I[1]);
......
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