E04HDF checks that a subroutine for calculating second derivatives of an objective function is consistent with a subroutine for calculating the corresponding first derivatives.
Routines for minimizing a function
$F\left({x}_{1},{x}_{2},\dots ,{x}_{n}\right)$ of the variables
${x}_{1},{x}_{2},\dots ,{x}_{n}$ may require you to provide a subroutine to evaluate the second derivatives of
$F$. E04HDF is designed to check the second derivatives calculated by such user-supplied subroutines. As well as the routine to be checked (
H), you must supply a subroutine (
FUNCT) to evaluate the first derivatives, and a point
$x={\left({x}_{1},{x}_{2},\dots ,{x}_{n}\right)}^{\mathrm{T}}$ at which the checks will be made. Note that E04HDF checks routines of the form required for
E04LBF.
E04HDF first calls user-supplied subroutines
FUNCT and
H to evaluate the first and second derivatives of
$F$ at
$x$. The user-supplied Hessian matrix (
$H$, say) is projected onto two orthogonal vectors
$y$ and
$z$ to give the scalars
${y}^{\mathrm{T}}Hy$ and
${z}^{\mathrm{T}}Hz$ respectively. The same projections of the Hessian matrix are also estimated by finite differences, giving
respectively, where
$g\left(\right)$ denotes the vector of first derivatives at the point in brackets and
$h$ is a small positive scalar. If the relative difference between
$p$ and
${y}^{\mathrm{T}}Hy$ or between
$q$ and
${z}^{\mathrm{T}}Hz$ is judged too large, an error indicator is set.
None.
If on entry
${\mathbf{IFAIL}}={\mathbf{0}}$ or
${-{\mathbf{1}}}$, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
IFAIL is set to
$2$ if
where
$h$ is set equal to
$\sqrt{\epsilon}$ (
$\epsilon $ being the
machine precision as given by
X02AJF) and other quantities are as defined in
Section 3.
E04HDF is not threaded by NAG in any implementation.
E04HDF makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
Suppose that it is intended to use
E04LBF to minimize
The following program could be used to check the second derivatives calculated by
H required. (The call of E04HDF is preceded by a call of
E04HCF to check
FUNCT which calculates the first derivatives.)
None.