Browse Source

RootFinding: OfFunctionAndDerivative fall back to Bisection instead of Brent (more robust)

v2
Christoph Ruegg 13 years ago
parent
commit
42731600ed
  1. 5
      src/Numerics/FindRoots.cs

5
src/Numerics/FindRoots.cs

@ -38,6 +38,7 @@ namespace MathNet.Numerics
public static double OfFunction(Func<double, double> f, double lowerBound, double upperBound, double accuracy = 1e-8)
{
double root;
if (Brent.TryFindRoot(f, lowerBound, upperBound, accuracy, 100, out root))
{
return root;
@ -54,11 +55,13 @@ namespace MathNet.Numerics
public static double OfFunctionAndDerivative(Func<double, double> f, Func<double, double> df, double lowerBound, double upperBound, double accuracy = 1e-8)
{
double root;
if (RobustNewtonRaphson.TryFindRoot(f, df, lowerBound, upperBound, accuracy, 100, 20, out root))
{
return root;
}
if (Brent.TryFindRoot(f, lowerBound, upperBound, accuracy, 100, out root))
if (Bisection.TryFindRoot(f, lowerBound, upperBound, accuracy, 100, out root))
{
return root;
}

Loading…
Cancel
Save