The function
e04kbc for minimizing a function of several variables requires you to supply a C function to evaluate the objective function
$F({x}_{1},{x}_{2},\dots ,{x}_{n})$ and its first derivatives.
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
$x={({x}_{1},{x}_{2},\dots ,{x}_{n})}^{\mathrm{T}}$ at which the check is to be made.
e04hcc first calls the supplied function
objfun to evaluate
$F$ and its first derivatives
${g}_{\mathit{j}}=\frac{\partial F}{\partial {x}_{\mathit{j}}}$, for
$\mathit{j}=1,2,\dots ,n$ at
$x$. The components of the user-supplied derivatives along two orthogonal directions (defined by unit vectors
${p}_{1}$ and
${p}_{2}$, say) are then calculated; these will be
${g}^{\mathrm{T}}{p}_{1}$ and
${g}^{\mathrm{T}}{p}_{2}$ respectively. The same components are also estimated by finite differences, giving quantities
where
$h$ is a small positive scalar. If the relative difference between
${v}_{1}$ and
${g}^{\mathrm{T}}{p}_{1}$ or between
${v}_{2}$ and
${g}^{\mathrm{T}}{p}_{2}$ is judged too large, an error indicator is set.
None.
fail is set to
NE_DERIV_ERRORS if
for
$k=1$ or
$2$. (See
Section 3 for definitions of the quantities involved.) The scalar
$h$ is set equal to
$\sqrt{\epsilon}$, where
$\epsilon $ is the
machine precision as given by
X02AJC.
Background information to multithreading can be found in the
Multithreading documentation.
The user-defined function
objfun is called three times.
Before using
e04hcc to check the calculation of first derivatives, you should be confident that
objfun is calculating
$F$ correctly. The usual way of checking the calculation of the function is to compare values of
$F\left(x\right)$ calculated by
objfun at non-trivial points
$x$ with values calculated independently. (‘Non-trivial’ means that, as when setting
$x$ before calling
e04hcc, coordinates such as
$0.0$ or
$1.0$ should be avoided.)
Suppose that it is intended to use
e04kbc to minimize
The following program could be used to check the first derivatives calculated by the required function
objfun. (The test of whether
$\mathbf{comm}\mathbf{\to}\mathbf{flag}\ne 0$ in
objfun is present for when
objfun is called by
e04kbc.
e04hcc will always call
objfun with
$\mathbf{comm}\mathbf{\to}\mathbf{flag}$ set to 2.)
None.