E04HCF checks that a subroutine for evaluating an objective function and its first derivatives produces derivative values which are consistent with the function values calculated.
Routines for minimizing a function of several variables may require you to supply a subroutine to evaluate the objective function
and its first derivatives. E04HCF is designed to check the derivatives calculated by such user-supplied subroutines . As well as the routine to be checked (
FUNCT), you must supply a point
at which the check will be made. Note that E04HCF checks routines of the form required for
E04KDF and
E04LBF.
E04HCF first calls
FUNCT to evaluate
and its first derivatives
, for
at
. The components of the user-supplied derivatives along two orthogonal directions (defined by unit vectors
and
, say) are then calculated; these will be
and
respectively. The same components are also estimated by finite differences, giving quantities
where
is a small positive scalar. If the relative difference between
and
or between
and
is judged too large, an error indicator is set.
None.
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
IFAIL is set to
if
for
. (See
Section 3 for definitions of the quantities involved.) The scalar
is set equal to
, where
is the
machine precision as given by
X02AJF.
Before using E04HCF to check the calculation of first derivatives, you should be confident that
FUNCT is calculating
correctly. The usual way of checking the calculation of the function is to compare values of
calculated by
FUNCT at nontrivial points
with values calculated independently. (‘Non-trivial’ means that, as when setting
before calling E04HCF, coordinates such as
or
should be avoided.)
E04HCF only checks the derivatives calculated when
. So, if
FUNCT is intended for use in conjunction with a minimization routine which may set
IFLAG to
, you must check that, for given settings of the
,
FUNCT produces the same values for the
when
IFLAG is set to
as when
IFLAG is set to
.
Suppose that it is intended to use
E04KDF to minimize
The following program could be used to check the first derivatives calculated by
FUNCT. (The tests of whether
or
in
FUNCT are present ready for when
FUNCT is called by
E04KDF. E04HCF will always call
FUNCT with
IFLAG set to 2.)
None.