DekkerBrentSolver.TryFindZero Method

Attempts to find a zero of the specified function within the given interval using a root-finding algorithm.

Definition

Namespace: Numerics.NET.EquationSolvers
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.0.0
C#
public static bool TryFindZero(
	Func<double, double> function,
	double lowerBound,
	double upperBound,
	out double result,
	double tolerance = 1.49011611938477E-08,
	int maxIterations = 200,
	double rightHandSide = 0
)

Parameters

function  Func<Double, Double>
A function of one variable for which to find a zero. The function should be continuous on the interval defined by lowerBound and upperBound.
lowerBound  Double
The lower bound of the interval in which to search for a zero.
upperBound  Double
The upper bound of the interval in which to search for a zero.
result  Double
When this method returns, contains the computed zero of the function if successful; otherwise, NaN.
tolerance  Double  (Optional)
The convergence tolerance for the zero-finding algorithm. Must be positive. The default is SqrtEpsilon.
maxIterations  Int32  (Optional)
The maximum number of iterations to perform before giving up. Must be positive. The default is 200.
rightHandSide  Double  (Optional)
The value for which the function is set equal to when searching for a zero. The method finds a value x such that function(x) = rightHandSide. The default is 0.0.

Return Value

Boolean
true if a zero was found within the specified interval and tolerance; otherwise, false.

Remarks

This method uses a variant of Brent's algorithm to locate a zero of the function. The function values at the interval endpoints must bracket a zero (i.e., the function must take opposite signs at lowerBound and upperBound). If the method fails to converge within the specified number of iterations, result will contain the best approximation found.

See Also