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.

Syntax

C#
public static void c05ay(
	double a,
	double b,
	double eps,
	double eta,
	C05..::..C05AY_F f,
	out double x,
	out int ifail
)
Visual Basic
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 _
)
Visual C++
public:
static void c05ay(
	double a, 
	double b, 
	double eps, 
	double eta, 
	C05..::..C05AY_F^ f, 
	[OutAttribute] double% x, 
	[OutAttribute] int% ifail
)
F#
static member c05ay : 
        a : float * 
        b : float * 
        eps : float * 
        eta : float * 
        f : C05..::..C05AY_F * 
        x : float byref * 
        ifail : int byref -> unit 

Parameters

a
Type: System..::..Double
On entry: a, the lower bound of the interval.
b
Type: System..::..Double
On entry: b, the upper bound of the interval.
Constraint: ba.
eps
Type: System..::..Double
On entry: the termination tolerance on x (see [Description]).
Constraint: eps>0.0.
eta
Type: System..::..Double
On entry: a value such that if fxeta, x is accepted as the zero. eta may be specified as 0.0 (see [Accuracy]).
f
Type: NagLibrary..::..C05..::..C05AY_F
f must evaluate the function f whose zero is to be determined.

A delegate of type C05AY_F.

x
Type: System..::..Double%
On exit: if ifail=0 or 2, x is the final approximation to the zero. If ifail=3, x is likely to be a pole of fx. Otherwise, x contains no useful information.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

c05ay attempts to obtain an approximation to a simple zero of the function fx given an initial interval a,b such that fa×fb0. The same core algorithm is used by c05az whose specification should be consulted for details of the method used.
The approximation x to the zero α is determined so that at least one of the following criteria is satisfied:
(i) x-αeps,
(ii) fxeta.

References

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

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
On entry, a=value and b=value.
Constraint: ab.
On entry, eps=value.
Constraint: eps>0.0.
On entry, fa and fb have the same sign with neither equalling 0.0: fa=value and fb=value.
ifail=2
No further improvement in the solution is possible. eps is too small: eps=value. The final value of x returned is an accurate approximation to the zero.
ifail=3
The function values in the interval a,b might contain a pole rather than a zero. Reducing eps may help in distinguishing between a pole and a zero.
ifail=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

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 ifail=2, although this may involve many more iterations than a lesser accuracy. You are recommended to set eta=0.0 and to use eps to control the accuracy, unless you have considerable knowledge of the size of fx for values of x near the zero.

Parallelism and Performance

None.

Further Comments

The time taken by c05ay depends primarily on the time spent evaluating f (see [Parameters]).
If it is important to determine an interval of relative length less than 2×eps 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.

Example

This example calculates an approximation to the zero of e-x-x within the interval 0,1 using a tolerance of eps=1.0E−5.

Example program (C#): c05aye.cs

Example program results: c05aye.r

See Also