naginterfaces.library.roots.contfn_​brent

naginterfaces.library.roots.contfn_brent(a, b, f, eps=1.1102230246251565e-13, eta=0.0, data=None)[source]

contfn_brent locates a simple zero of a continuous function in a given interval using Brent’s method, which is a combination of nonlinear interpolation, linear extrapolation and bisection.

For full information please refer to the NAG Library document for c05ay

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/c05/c05ayf.html

Parameters
afloat

, the lower bound of the interval.

bfloat

, the upper bound of the interval.

fcallable retval = f(x, data=None)

must evaluate the function whose zero is to be determined.

Parameters
xfloat

The point at which the function must be evaluated.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
retvalfloat

The value of evaluated at .

epsfloat, optional

The termination tolerance on (see Notes).

etafloat, optional

A value such that if , is accepted as the zero. may be specified as (see Accuracy).

dataarbitrary, optional

User-communication data for callback functions.

Returns
xfloat

If the function exits successfully or = 2, is the final approximation to the zero. If = 3, is likely to be a pole of . Otherwise, contains no useful information.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and have the same sign with neither equalling : and .

Warns
NagAlgorithmicWarning
(errno )

No further improvement in the solution is possible. is too small: . The final value of returned is an accurate approximation to the zero.

(errno )

The function values in the interval might contain a pole rather than a zero. Reducing may help in distinguishing between a pole and a zero.

Notes

contfn_brent attempts to obtain an approximation to a simple zero of the function given an initial interval such that . The same core algorithm is used by contfn_brent_rcomm() whose specification should be consulted for details of the method used.

The approximation to the zero is determined so that at least one of the following criteria is satisfied:

  1. ,

  2. .

References

Brent, R P, 1973, Algorithms for Minimization Without Derivatives, Prentice–Hall