Namespaces

Types in MathNet.Numerics.RootFinding

Type Brent

Namespace MathNet.Numerics.RootFinding

Algorithm by Brent, Van Wijngaarden, Dekker et al. Implementation inspired by Press, Teukolsky, Vetterling, and Flannery, "Numerical Recipes in C", 2nd edition, Cambridge University Press

Static Functions

Public Static Functions

double FindRoot(Func<double, double> f, double lowerBound, double upperBound, double accuracy, int maxIterations)

Find a solution of the equation f(x)=0.
Parameters
Func<double, double> f

The function to find roots from.

double lowerBound

The low value of the range where the root is supposed to be.

double upperBound

The high value of the range where the root is supposed to be.

double accuracy

Desired accuracy. The root will be refined until the accuracy or the maximum number of iterations is reached. Default 1e-8. Must be greater than 0.

int maxIterations

Maximum number of iterations. Default 100.

Return
double

Returns the root with the specified accuracy.

double FindRootExpand(Func<double, double> f, double guessLowerBound, double guessUpperBound, double accuracy, int maxIterations, double expandFactor, int maxExpandIteratons)

Find a solution of the equation f(x)=0.
Parameters
Func<double, double> f

The function to find roots from.

double guessLowerBound

Guess for the low value of the range where the root is supposed to be. Will be expanded if needed.

double guessUpperBound

Guess for the high value of the range where the root is supposed to be. Will be expanded if needed.

double accuracy

Desired accuracy. The root will be refined until the accuracy or the maximum number of iterations is reached. Default 1e-8. Must be greater than 0.

int maxIterations

Maximum number of iterations. Default 100.

double expandFactor

Factor at which to expand the bounds, if needed. Default 1.6.

int maxExpandIteratons

Maximum number of expand iterations. Default 100.

Return
double

Returns the root with the specified accuracy.

bool TryFindRoot(Func<double, double> f, double lowerBound, double upperBound, double accuracy, int maxIterations, Double& root)