naginterfaces.library.roots.contfn_brent_interval¶
- naginterfaces.library.roots.contfn_brent_interval(x, f, h=0.1, eps=1.1102230246251565e-13, eta=0.0, data=None)[source]¶
contfn_brent_interval
locates a simple zero of a continuous function from a given starting value. It uses a binary search to locate an interval containing a zero of the function, then Brent’s method, which is a combination of nonlinear interpolation, linear extrapolation and bisection, to locate the zero precisely.For full information please refer to the NAG Library document for c05au
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/c05/c05auf.html
- Parameters
- xfloat
An initial approximation to the zero.
- 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 at the specified point.
- hfloat, optional
A step length for use in the binary search for an interval containing the zero. The maximum interval searched is .
- 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 = 4, is the final approximation to the zero.
If = 3, is likely to be a pole of .
Otherwise, contains no useful information.
- afloat
The lower bound of the interval resulting from the binary search
- bfloat
The upper bound of the interval resulting from the binary search
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: (to machine accuracy).
- (errno )
An interval containing the zero could not be found. Increasing and calling
contfn_brent_interval
again will increase the range searched for the zero. Decreasing and callingcontfn_brent_interval
again will refine the mesh used in the search for the zero.
- Warns
- NagAlgorithmicWarning
- (errno )
Solution may be a pole rather than a zero.
- (errno )
The tolerance has been set too small for the problem being solved. However, the value returned is a good approximation to the zero. .
- Notes
contfn_brent_interval
attempts to locate an interval containing a simple zero of the function by a binary search starting from the initial point and using repeated calls tocontfn_interval_rcomm()
. If this search succeeds, then the zero is determined to a user-specified accuracy by a call tocontfn_brent()
. The specifications of functionscontfn_interval_rcomm()
andcontfn_brent()
should be consulted for details of the methods used.The approximation to the zero is determined so that at least one of the following criteria is satisfied:
,
.
- References
Brent, R P, 1973, Algorithms for Minimization Without Derivatives, Prentice–Hall