E04ABF (pdf version)
Chapter Contents
Chapter Introduction
NAG Library Manual

NAG Fortran Library Routine Document

E04ABF/E04ABA

Note: before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

     1 Purpose
     7 Accuracy

1  Purpose

E04ABF/E04ABA 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).
E04ABA is a version of E04ABF that has additional parameters in order to make it safe for use in multithreaded applications (see Section 5).

2  Specification

2.1  Specification for E04ABF

SUBROUTINE E04ABF (FUNCT, E1, E2, A, B, MAXCAL, X, F, IFAIL)
INTEGERMAXCAL, IFAIL
double precisionE1, E2, A, B, X, F
EXTERNALFUNCT

2.2  Specification for E04ABA

SUBROUTINE E04ABA (FUNCT, E1, E2, A, B, MAXCAL, X, F, IUSER, RUSER, IFAIL)
INTEGERMAXCAL, IUSER(*), IFAIL
double precisionE1, E2, A, B, X, F, RUSER(*)
EXTERNALFUNCT

3  Description

E04ABF/E04ABA 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 (sub)program 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, E04ABF/E04ABA will normally find one of the minima.

4  References

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

5  Parameters

1:     FUNCT – SUBROUTINE, supplied by the user.External Procedure
FUNCT must be declared as EXTERNAL in the (sub)program from which E04ABF/E04ABA is called. Parameters denoted as Input must not be changed by this procedure.
2:     E1 – double precisionInput/Output
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 ε), E1will be reset to the default value ε before starting the minimization process.
3:     E2 – double precisionInput/Output
On exit: if you set E2 to 0.0 (or to any value less than ε), E2 will be reset to the default value ε.
4:     A – double precisionInput/Output
On entry: the lower bound a of the interval containing a minimum.
On exit: an improved lower bound on the position of the minimum.
5:     B – double precisionInput/Output
On entry: the upper bound b of the interval containing a minimum.
On exit: an improved upper bound on the position of the minimum.
6:     MAXCAL – INTEGERInput/Output
On exit: the total number of times that FUNCT was actually called.
7:     X – double precisionOutput
On exit: the estimated position of the minimum.
8:     F – double precisionOutput
9:     IFAIL – INTEGERInput/Output
Note: for E04ABA, IFAIL does not occur in this position in the parameter list. See the additional parameters described below.
On initial entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Chapter P01 for details.
On final exit: IFAIL =0 unless the routine detects an error (see Section 6).
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if IFAIL 0 on exit, the recommended value is -1. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
Note: the following are additional parameters for specific use with E04ABA. Users of E04ABF therefore need not read the remainder of this description.
9:     IUSER(*) – INTEGER arrayUser Workspace
IUSER is not used by E04ABA, but is passed directly to the user-supplied (sub)program FUNCT and may be used to pass information to that routine.
10:   RUSER(*) – double precision arrayUser Workspace
RUSER is not used by E04ABA, but is passed directly to the user-supplied (sub)program FUNCT and may be used to pass information to that routine.
11:   IFAIL – INTEGERInput/Output

6  Error Indicators and Warnings

If on entry IFAIL = 0 or −1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
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 the user-supplied (sub)program FUNCT. If no mistake can be found in FUNCT, restart E04ABF/E04ABA (preferably with values of A and B given on exit from the previous call of E04ABF/E04ABA).

7  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.

8  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, E04ABF/E04ABA will determine an approximation x (and improved bounds a and b) for one of the minima.
If E04ABF/E04ABA 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 user-supplied (sub)program. Therefore FUNCT should be programmed to calculate Fx as accurately as possible, so that E04ABF/E04ABA will not be liable to find a spurious minimum.

9  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 E04ABF/E04ABA can be used to obtain a good approximation to the position of a minimum.

9.1  Program Text

Note: the following program illustrates the use of E04ABF. An equivalent program illustrating the use of E04ABA is available with the supplied Library and is also available from the NAG web site.

Program Text (e04abfe.f)

9.2  Program Data

None.

9.3  Program Results

Program Results (e04abfe.r)


E04ABF (pdf version)
Chapter Contents
Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2006