The function
nag_opt_bounds_deriv (e04kbc) for minimizing a function of several variables requires you to supply a C function to evaluate the objective function
and its first derivatives.
nag_opt_check_deriv (e04hcc) is designed to check the derivatives calculated by such a user-supplied function. As well as the function to be checked (
objfun), you must supply a point
at which the check is to be made.
nag_opt_check_deriv (e04hcc) first calls the supplied function
objfun 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.
fail is set to
NE_DERIV_ERRORS if
for
or
. (See
Section 3 for definitions of the quantities involved.) The scalar
is set equal to
, where
is the
machine precision as given by
nag_machine_precision (X02AJC).
The user-defined function
objfun is called three times.
Before using
nag_opt_check_deriv (e04hcc) to check the calculation of first derivatives, you should be confident that
objfun is calculating
correctly. The usual way of checking the calculation of the function is to compare values of
calculated by
objfun at non-trivial points
with values calculated independently. (‘Non-trivial’ means that, as when setting
before calling
nag_opt_check_deriv (e04hcc), coordinates such as 0.0 or 1.0 should be avoided.)
Suppose that it is intended to use
nag_opt_bounds_deriv (e04kbc) to minimize
The following program could be used to check the first derivatives calculated by the required function
objfun. (The test of whether
in
objfun is present for when
objfun is called by
nag_opt_bounds_deriv (e04kbc).
nag_opt_check_deriv (e04hcc) will always call
objfun with
set to 2.)
None.