e04ya checks that a user-supplied method for evaluating a vector of functions and the matrix of their first derivatives produces derivative values which are consistent with the function values calculated.
Syntax
C# |
---|
public static void e04ya( int m, int n, E04..::..E04YA_LSQFUN lsqfun, double[] x, double[] fvec, double[,] fjac, out int ifail ) |
Visual Basic |
---|
Public Shared Sub e04ya ( _ m As Integer, _ n As Integer, _ lsqfun As E04..::..E04YA_LSQFUN, _ x As Double(), _ fvec As Double(), _ fjac As Double(,), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void e04ya( int m, int n, E04..::..E04YA_LSQFUN^ lsqfun, array<double>^ x, array<double>^ fvec, array<double,2>^ fjac, [OutAttribute] int% ifail ) |
F# |
---|
static member e04ya : m : int * n : int * lsqfun : E04..::..E04YA_LSQFUN * x : float[] * fvec : float[] * fjac : 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..::..E04YA_LSQFUNlsqfun must calculate the vector of values and their first derivatives at any point . (The minimization methods mentioned in [Description] give you the option of resetting a parameter to terminate immediately. e04ya will also terminate immediately, without finishing the checking process, if the parameter in question is reset.)
A delegate of type E04YA_LSQFUN.
- 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 derivatives calculated by lsqfun. ‘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 can 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:
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
Routines for minimizing a sum of squares of nonlinear functions (or ‘residuals’), , for and , may require you to supply a method to evaluate the and their first derivatives. e04ya checks the derivatives calculated by such user-supplied delegates, e.g., methods of the form required for (E04GBF not in this release) e04gd e04he. As well as the method to be checked (lsqfun), you must supply a point at which the check will be made. e04ya is essentially identical to CHKLSJ in the NPL Algorithms Library.
e04ya first calls lsqfun to evaluate the and their first derivatives, and uses these to calculate the sum of squares ,
and its first derivatives , for . The components of 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.
References
None.
Error Indicators and Warnings
Note: e04ya 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 ,
- You should check carefully the derivation and programming of expressions for the , because it is very unlikely that lsqfun is calculating them correctly.
Accuracy
ifail is set to if
for . (See [Description] for definitions of the quantities involved.) The scalar is set equal to , where is the machine precision as given by x02aj.
Parallelism and Performance
None.
Further Comments
Before using e04ya to check the calculation of the first derivatives, you should be confident that lsqfun is calculating the residuals correctly.
e04ya only checks the derivatives calculated by a user-supplied method when . So, if lsqfun is intended for use in conjunction with a minimization method which may set iflag to , you must check that, for given settings of the , lsqfun produces the same values for the when iflag is set to as when iflag is set to .