Calc.Brent Method

Computes a Brent-style root bracketing. Returns true on success, or false on failure. Failure can only happen if the function value at xmin and xmax has the same sign, and the function values at xmin/xmax is not within zero tolerance.
public static bool Brent( 
   double xmin
   double xmax
   Func<double, double> function
   out double res
   double tol
   double zerotol 
)

Parameters

xmin
double

Lower bound for root search.

xmax
double

Upper bound for root search.

function
Func<double, double>

The function to evaluate.

res
double

The x value for the root.

tol
double

The iteration stops when this tolerance is reached. If never reached it stops after 1000 iterations.

zerotol
double

If abs(funtion(xmin or xmax)) xmin/xmax is smaller than this value and same signs for xmin/xmax is sent, it is reported as success. This is to find roots close to 0 but with a small tolerance error. Set to negative to disable.

Return Value

bool

.NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

In this article

Definition