e04ab searches for a minimum, in a given finite interval, of a continuous function of a single variable, using function values only. The method (based on quadratic interpolation) is intended for functions which have a continuous first derivative (although it will usually work if the derivative has occasional discontinuities).

Syntax

C#
public static void e04ab(
	E04..::..E04AB_FUNCT funct,
	ref double e1,
	ref double e2,
	ref double a,
	ref double b,
	ref int maxcal,
	out double x,
	out double f,
	out int ifail
)
Visual Basic
Public Shared Sub e04ab ( _
	funct As E04..::..E04AB_FUNCT, _
	ByRef e1 As Double, _
	ByRef e2 As Double, _
	ByRef a As Double, _
	ByRef b As Double, _
	ByRef maxcal As Integer, _
	<OutAttribute> ByRef x As Double, _
	<OutAttribute> ByRef f As Double, _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void e04ab(
	E04..::..E04AB_FUNCT^ funct, 
	double% e1, 
	double% e2, 
	double% a, 
	double% b, 
	int% maxcal, 
	[OutAttribute] double% x, 
	[OutAttribute] double% f, 
	[OutAttribute] int% ifail
)
F#
static member e04ab : 
        funct : E04..::..E04AB_FUNCT * 
        e1 : float byref * 
        e2 : float byref * 
        a : float byref * 
        b : float byref * 
        maxcal : int byref * 
        x : float byref * 
        f : float byref * 
        ifail : int byref -> unit 

Parameters

funct
Type: NagLibrary..::..E04..::..E04AB_FUNCT
You must supply this method to calculate the value of the function Fx at any point x in a,b. It should be tested separately before being used in conjunction with e04ab.

A delegate of type E04AB_FUNCT.

e1
Type: System..::..Double%
On entry: the relative accuracy to which the position of a minimum is required. (Note that, since e1 is a relative tolerance, the scaling of x is automatically taken into account.)
e1 should be no smaller than 2ε, and preferably not much less than ε, where ε is the machine precision.
On exit: if you set e1 to 0.0 (or to any value less than ε), e1 will be reset to the default value ε before starting the minimization process.
e2
Type: System..::..Double%
On entry: the absolute accuracy to which the position of a minimum is required. e2 should be no smaller than 2ε.
On exit: if you set e2 to 0.0 (or to any value less than ε), e2 will be reset to the default value ε.
a
Type: System..::..Double%
On entry: the lower bound a of the interval containing a minimum.
On exit: an improved lower bound on the position of the minimum.
b
Type: System..::..Double%
On entry: the upper bound b of the interval containing a minimum.
On exit: an improved upper bound on the position of the minimum.
maxcal
Type: System..::..Int32%
On entry: the maximum number of calls of Fx to be allowed.
Constraint: maxcal3. (Few problems will require more than 30.)
There will be an error exit (see [Error Indicators and Warnings]) after maxcal calls of funct
On exit: the total number of times that funct was actually called.
x
Type: System..::..Double%
On exit: the estimated position of the minimum.
f
Type: System..::..Double%
On exit: the function value at the final point given in x.
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

e04ab is applicable to problems of the form:
MinimizeFx  subject to  axb.
It normally computes a sequence of x values which tend in the limit to a minimum of Fx subject to the given bounds. It also progressively reduces the interval a,b in which the minimum is known to lie. It uses the safeguarded quadratic-interpolation method described in Gill and Murray (1973).
You must supply a funct to evaluate Fx. The parameters e1 and e2 together specify the accuracy
Tolx=e1×x+e2
to which the position of the minimum is required. Note that funct is never called at any point which is closer than Tolx to a previous point.
If the original interval a,b contains more than one minimum, e04ab will normally find one of the minima.

References

Gill P E and Murray W (1973) Safeguarded steplength algorithms for optimization using descent methods NPL Report NAC 37 National Physical Laboratory

Error Indicators and Warnings

Note: e04ab may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
ifail=1
On entry,a+e2b,
ormaxcal<3,
ifail=2
The number of calls of funct has exceeded maxcal. This may have happened simply because maxcal was set too small for a particular problem, or may be due to a mistake in funct. If no mistake can be found in funct, restart e04ab (preferably with the values of a and b given on exit from the previous call of e04ab).
ifail=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

If Fx is δ-unimodal for some δ<Tolx, where Tolx=e1×x+e2, then, on exit, x approximates the minimum of Fx in the original interval a,b with an error less than 3×Tolx.

Parallelism and Performance

None.

Further Comments

Timing depends on the behaviour of Fx, the accuracy demanded and the length of the interval a,b. Unless Fx can be evaluated very quickly, the run time will usually be dominated by the time spent in funct.
If Fx has more than one minimum in the original interval a,b, e04ab will determine an approximation x (and improved bounds a and b) for one of the minima.
If e04ab finds an x such that Fx-δ1>Fx<Fx+δ2 for some δ1,δ2Tolx, the interval x-δ1,x+δ2 will be regarded as containing a minimum, even if Fx is less than Fx-δ1 and Fx+δ2 only due to rounding errors in the method. Therefore funct should be programmed to calculate Fx as accurately as possible, so that e04ab will not be liable to find a spurious minimum.

Example

A sketch of the function
Fx=sinxx
shows that it has a minimum somewhere in the range 3.5,5.0. The following program shows how e04ab can be used to obtain a good approximation to the position of a minimum.

Example program (C#): e04abe.cs

Example program results: e04abe.r

See Also