Routines for minimizing a sum of squares of
nonlinear functions (or ‘residuals’),
, for
and
, may require you to supply a subroutine to evaluate the quantities
for
and
.
e04ybf is designed to check the
calculated by such user-supplied subroutines. As well as the routine to be checked (
lsqhes), you must supply a subroutine (
lsqfun) to evaluate the
and their first derivatives, and a point
at which the checks will be made. Note that
e04ybf checks routines of the form required by
e04hef.
e04ybf is essentially identical to CHKLSH in the NPL Algorithms Library.
e04ybf first calls user-supplied subroutines
lsqfun and
lsqhes to evaluate the first derivatives and the
at
. Let
denote the
matrix of first derivatives of the residuals. The Hessian matrix of the sum of squares,
is calculated and 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 gradient vector of the sum of squares 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.
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
ifail is set to
if
where
is set equal to
(
being the
machine precision as given by
x02ajf) and other quantities are defined as in
Section 3.
Background information to multithreading can be found in the
Multithreading documentation.
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
e04hef to find least squares estimates of
and
in the model
using the
sets of data given in the following table.
This example program could be used to check the
calculated by
lsqhes required. (The call of
e04ybf is preceded by a call of
e04yaf to check
lsqfun which calculates the first derivatives.)