nag_opt_check_2nd_deriv (e04hdc) checks that a user-supplied function for calculating second derivatives of an objective function is consistent with a user-supplied function for calculating the corresponding first derivatives.
Routines for minimizing a function
of the variables
may require you to provide a subroutine to evaluate the second derivatives of
. nag_opt_check_2nd_deriv (e04hdc) is designed to check the second derivatives calculated by such user-supplied functions. As well as the function to be checked (
hessfun), you must supply a function (
objfun) to evaluate the first derivatives, and a point
at which the checks will be made. Note that nag_opt_check_2nd_deriv (e04hdc) checks functions of the form required for
nag_opt_bounds_2nd_deriv (e04lbc).
nag_opt_check_2nd_deriv (e04hdc) first calls
objfun and
hessfun to evaluate the first and second derivatives of
at
. The user-supplied Hessian matrix (
, say) is projected onto two orthogonal vectors
and
to give the scalars
and
respectively. The same projections of the Hessian matrix are also estimated by finite differences, giving
respectively, where
denotes the vector of first derivatives at the point in brackets and
is a small positive scalar. If the relative difference between
and
or between
and
is judged too large, an error indicator is set.
None.
The error
NE_DERIV_ERRORS is returned if
where
is set equal to
(
being the
machine precision as given by
nag_machine_precision (X02AJC) and other quantities are as defined in
Section 3.
Not applicable.
nag_opt_check_2nd_deriv (e04hdc) calls
hessfun once and
objfun three times.
Suppose that it is intended to use
nag_opt_bounds_2nd_deriv (e04lbc) to minimize
The following program could be used to check the second derivatives calculated by the required
hessfun function. (The call of nag_opt_check_2nd_deriv (e04hdc) is preceded by a call of
nag_opt_check_deriv (e04hcc) to check the function
objfun which calculates the first derivatives.)
None.