Skip to content

Commit f82490a

Browse files
committed
Delayed evalution of fmin and fmax.
1 parent 4c65b58 commit f82490a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Numerics/RootFinding/RobustNewtonRaphson.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ public static bool TryFindRoot(Func<double, double> f, Func<double, double> df,
7474
throw new ArgumentOutOfRangeException(nameof(accuracy), "Must be greater than zero.");
7575
}
7676

77-
double fmin = f(lowerBound);
78-
double fmax = f(upperBound);
79-
8077
root = lowerBound + 0.5 * (upperBound - lowerBound);
8178
double fx = f(root);
8279
if (Math.Abs(fx) < accuracy)
8380
{
8481
return true;
8582
}
8683

84+
double fmin = f(lowerBound);
85+
double fmax = f(upperBound);
86+
8787
if (Math.Abs(fmin) < accuracy)
8888
{
8989
root = lowerBound;

0 commit comments

Comments
 (0)