e04yb checks that a user-supplied method for evaluating the second derivative term of the Hessian matrix of a sum of squares is consistent with a user-supplied method for calculating the corresponding first derivatives.
Syntax
C# |
---|
public static void e04yb( int m, int n, E04..::..E04YB_LSQFUN lsqfun, E04..::..E04YB_LSQHES lsqhes, double[] x, double[] fvec, double[,] fjac, double[] b, out int ifail ) |
Visual Basic |
---|
Public Shared Sub e04yb ( _ m As Integer, _ n As Integer, _ lsqfun As E04..::..E04YB_LSQFUN, _ lsqhes As E04..::..E04YB_LSQHES, _ x As Double(), _ fvec As Double(), _ fjac As Double(,), _ b As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void e04yb( int m, int n, E04..::..E04YB_LSQFUN^ lsqfun, E04..::..E04YB_LSQHES^ lsqhes, array<double>^ x, array<double>^ fvec, array<double,2>^ fjac, array<double>^ b, [OutAttribute] int% ifail ) |
F# |
---|
static member e04yb : m : int * n : int * lsqfun : E04..::..E04YB_LSQFUN * lsqhes : E04..::..E04YB_LSQHES * x : float[] * fvec : float[] * fjac : float[,] * b : float[] * ifail : int byref -> unit |
Parameters
- m
- Type: System..::..Int32On entry: the number of residuals, , and the number of variables, .Constraint: .
- n
- Type: System..::..Int32On entry: the number of residuals, , and the number of variables, .Constraint: .
- lsqfun
- Type: NagLibrary..::..E04..::..E04YB_LSQFUNlsqfun must calculate the vector of values and their first derivatives at any point . (e04he gives you the option of resetting parameters of lsqfun to cause the minimization process to terminate immediately. e04yb will also terminate immediately, without finishing the checking process, if the parameter in question is reset.)
A delegate of type E04YB_LSQFUN.
- lsqhes
- Type: NagLibrary..::..E04..::..E04YB_LSQHESlsqhes must calculate the elements of the symmetric matrixat any point , where is the Hessian matrix of . (As with lsqfun, a parameter can be set to cause immediate termination.)
A delegate of type E04YB_LSQHES.
- x
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: , for , must be set to the coordinates of a suitable point at which to check the calculated by lsqhes. ‘Obvious’ settings, such as or , should not be used since, at such particular points, incorrect terms may take correct values (particularly zero), so that errors could go undetected. For a similar reason, it is preferable that no two elements of x should have the same value.
- fvec
- Type: array<System..::..Double>[]()[][]An array of size [m]
- fjac
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, n]Note: dim1 must satisfy the constraint:
- b
- Type: array<System..::..Double>[]()[][]An array of size [lb]
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
Methods for minimizing a sum of squares of nonlinear functions (or ‘residuals’), , for and , may require you to supply a method to evaluate the quantities
for and . e04yb is designed to check the calculated by such user-supplied delegates. As well as the method to be checked (lsqhes), you must supply a method (lsqfun) to evaluate the and their first derivatives, and a point at which the checks will be made. Note that e04yb checks methods of the form required by e04he. e04yb is essentially identical to CHKLSH in the NPL Algorithms Library.
e04yb first calls user-supplied delegates 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.
References
None.
Error Indicators and Warnings
Note: e04yb may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface
(LDFJAC, IW, LIW, W, LW) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.
On entry, , or , or ,
- You should check carefully the derivation and programming of expressions for the , because it is very unlikely that lsqhes is calculating them correctly.
Accuracy
ifail is set to if
where is set equal to ( being the machine precision as given by x02aj) and other quantities are defined as in [Description].
Parallelism and Performance
None.