E04YBF checks that a user-supplied subroutine for evaluating the second derivative term of the Hessian matrix of a sum of squares is consistent with a user-supplied subroutine for calculating the corresponding first derivatives.
SUBROUTINE E04YBF ( |
M, N, LSQFUN, LSQHES, X, FVEC, FJAC, LDFJAC, B, LB, IW, LIW, W, LW, IFAIL) |
INTEGER |
M, N, LDFJAC, LB, IW(LIW), LIW, LW, IFAIL |
REAL (KIND=nag_wp) |
X(N), FVEC(M), FJAC(LDFJAC,N), B(LB), W(LW) |
EXTERNAL |
LSQFUN, LSQHES |
|
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
by
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.
Not applicable.
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.)