NAG Library Routine Document
E04ABF/E04ABA
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
INTEGER |
MAXCAL, IFAIL |
REAL (KIND=nag_wp) |
E1, E2, A, B, X, F |
EXTERNAL |
FUNCT |
|
2.2 Specification for E04ABA
SUBROUTINE E04ABA ( |
FUNCT, E1, E2, A, B, MAXCAL, X, F, IUSER, RUSER, IFAIL) |
INTEGER |
MAXCAL, IUSER(*), IFAIL |
REAL (KIND=nag_wp) |
E1, E2, A, B, X, F, RUSER(*) |
EXTERNAL |
FUNCT |
|
3 Description
E04ABF/E04ABA is applicable to problems of the form:
It normally computes a sequence of
values which tend in the limit to a minimum of
subject to the given bounds. It also progressively reduces the interval
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
. The parameters
E1 and
E2 together specify the accuracy
to which the position of the minimum is required. Note that
FUNCT is never called at any point which is closer than
to a previous point.
If the original interval 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: – SUBROUTINE, supplied by the user.External Procedure
-
You must supply this routine to calculate the value of the function at any point in . It should be tested separately before being used in conjunction with E04ABF/E04ABA.
The specification of
FUNCT
for E04ABF is:
SUBROUTINE FUNCT ( |
XC, FC) |
REAL (KIND=nag_wp) |
XC, FC |
|
The specification of
FUNCT
for E04ABA is:
INTEGER |
IUSER(*) |
REAL (KIND=nag_wp) |
XC, FC, RUSER(*) |
|
- 1: – REAL (KIND=nag_wp)Input
-
On entry: the point at which the value of is required.
- 2: – REAL (KIND=nag_wp)Output
-
On exit: must be set to the value of the function at the current point .
- Note: the following are additional parameters for specific use with E04ABA. Users of E04ABF therefore need not read the remainder of this description.
- 3: – INTEGER arrayUser Workspace
- 4: – REAL (KIND=nag_wp) arrayUser Workspace
-
FUNCT is called with the parameters
IUSER and
RUSER as supplied to E04ABF/E04ABA. You are free to use the arrays
IUSER and
RUSER to supply information to
FUNCT as an alternative to using COMMON global variables.
FUNCT must either be a module subprogram USEd by, or 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: – REAL (KIND=nag_wp)Input/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
is automatically taken into account.)
E1 should be no smaller than
, and preferably not much less than
, where
is the
machine precision.
On exit: if you set
E1 to
(or to any value less than
),
E1 will be reset to the default value
before starting the minimization process.
- 3: – REAL (KIND=nag_wp)Input/Output
-
On entry: the absolute accuracy to which the position of a minimum is required.
E2 should be no smaller than
.
On exit: if you set
E2 to
(or to any value less than
),
E2 will be reset to the default value
.
- 4: – REAL (KIND=nag_wp)Input/Output
-
On entry: the lower bound of the interval containing a minimum.
On exit: an improved lower bound on the position of the minimum.
- 5: – REAL (KIND=nag_wp)Input/Output
-
On entry: the upper bound of the interval containing a minimum.
On exit: an improved upper bound on the position of the minimum.
- 6: – INTEGERInput/Output
-
On entry: the maximum number of calls of to be allowed.
Constraint:
. (Few problems will require more than
.)
There will be an error exit (see
Section 6) after
MAXCAL calls of
FUNCT
On exit: the total number of times that
FUNCT was actually called.
- 7: – REAL (KIND=nag_wp)Output
-
On exit: the estimated position of the minimum.
- 8: – REAL (KIND=nag_wp)Output
-
On exit: the function value at the final point given in
X.
- 9: – INTEGERInput/Output
-
Note: for E04ABA, IFAIL does not occur in this position in the parameter list. See the additional parameters described below.
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if
on exit, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
- Note: the following are additional parameters for specific use with E04ABA. Users of E04ABF therefore need not read the remainder of this description.
- 9: – INTEGER arrayUser Workspace
- 10: – REAL (KIND=nag_wp) arrayUser Workspace
-
IUSER and
RUSER are not used by E04ABF/E04ABA, but are passed directly to
FUNCT and may be used to pass information to this routine as an alternative to using COMMON global variables.
- 11: – INTEGERInput/Output
-
Note: see the parameter description for
IFAIL above.
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Note: E04ABF/E04ABA may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
-
On entry, | , |
or | , |
-
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 E04ABF/E04ABA (preferably with the values of
A and
B given on exit from the previous call of E04ABF/E04ABA).
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
If is -unimodal for some , where , then, on exit, approximates the minimum of in the original interval with an error less than .
8 Parallelism and Performance
Not applicable.
Timing depends on the behaviour of
, the accuracy demanded and the length of the interval
. Unless
can be evaluated very quickly, the run time will usually be dominated by the time spent in
FUNCT.
If has more than one minimum in the original interval , E04ABF/E04ABA will determine an approximation (and improved bounds and ) for one of the minima.
If E04ABF/E04ABA finds an
such that
for some
, the interval
will be regarded as containing a minimum, even if
is less than
and
only due to rounding errors in the subroutine. Therefore
FUNCT should be programmed to calculate
as accurately as possible, so that E04ABF/E04ABA will not be liable to find a spurious minimum.
10 Example
A sketch of the function
shows that it has a minimum somewhere in the range
. The following program shows how E04ABF/E04ABA can be used to obtain a good approximation to the position of a minimum.
10.1 Program Text
Note: the following programs illustrate the use of E04ABF and E04ABA.
Program Text (e04abfe.f90)
Program Text (e04abae.f90)
10.2 Program Data
None.
10.3 Program Results
Program Results (e04abfe.r)
Program Results (e04abae.r)