c05ay 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.
Public Shared Sub c05ay ( _ a As Double, _ b As Double, _ eps As Double, _ eta As Double, _ f As C05..::..C05AY_F, _ <OutAttribute> ByRef x As Double, _ <OutAttribute> ByRef ifail As Integer _ )
public: static void c05ay( double a, double b, double eps, double eta, C05..::..C05AY_F^ f, [OutAttribute] double% x, [OutAttribute] int% ifail )
- Type: System..::..DoubleOn entry: , the lower bound of the interval.
- Type: System..::..DoubleOn entry: , the upper bound of the interval.Constraint: .
- Type: System..::..DoubleOn entry: the termination tolerance on (see [Description]).Constraint: .
- Type: System..::..Double
- Type: NagLibrary..::..C05..::..C05AY_Ff must evaluate the function whose zero is to be determined.
A delegate of type C05AY_F.
- Type: System..::..Double%
c05ay 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 c05az 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:
Brent R P (1973) Algorithms for Minimization Without Derivatives Prentice–Hall
Errors or warnings detected by the method:
On entry, and .
Constraint: .On entry, .
Constraint: .On entry, and have the same sign with neither equalling : and .
The function values in the interval might contain a pole rather than a zero. Reducing eps may help in distinguishing between a pole and a zero.
The levels of accuracy depend on the values of eps and eta. If full machine accuracy is required, they may be set very small, resulting in an exit with , although this may involve many more iterations than a lesser accuracy. You are recommended to set and to use eps to control the accuracy, unless you have considerable knowledge of the size of for values of near the zero.
If it is important to determine an interval of relative length less than containing the zero, or if f is expensive to evaluate and the number of calls to f is to be restricted, then use of c05az is recommended. Use of c05az is also recommended when the structure of the problem to be solved does not permit a simple f to be written: the reverse communication facilities of c05az are more flexible than the direct communication of f required by c05ay.
This example calculates an approximation to the zero of within the interval using a tolerance of .