e04hd checks that a method for calculating second derivatives of an objective function is consistent with a method for calculating the corresponding first derivatives.
Syntax
C# |
---|
public static void e04hd( int n, E04..::..E04HD_FUNCT funct, E04..::..E04HD_H h, double[] x, double[] g, double[] hesl, double[] hesd, out int ifail ) |
Visual Basic |
---|
Public Shared Sub e04hd ( _ n As Integer, _ funct As E04..::..E04HD_FUNCT, _ h As E04..::..E04HD_H, _ x As Double(), _ g As Double(), _ hesl As Double(), _ hesd As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void e04hd( int n, E04..::..E04HD_FUNCT^ funct, E04..::..E04HD_H^ h, array<double>^ x, array<double>^ g, array<double>^ hesl, array<double>^ hesd, [OutAttribute] int% ifail ) |
F# |
---|
static member e04hd : n : int * funct : E04..::..E04HD_FUNCT * h : E04..::..E04HD_H * x : float[] * g : float[] * hesl : float[] * hesd : float[] * ifail : int byref -> unit |
Parameters
- n
- Type: System..::..Int32On entry: the number of independent variables in the objective function.Constraint: .
- funct
- Type: NagLibrary..::..E04..::..E04HD_FUNCTfunct must evaluate the function and its first derivatives at a given point. (e04lb gives you the option of resetting parameters of funct to cause the minimization process to terminate immediately. e04hd will also terminate immediately, without finishing the checking process, if the parameter in question is reset.)
A delegate of type E04HD_FUNCT.
- h
- Type: NagLibrary..::..E04..::..E04HD_Hh must evaluate the second derivatives of the function at a given point. (As with funct, a parameter can be set to cause immediate termination.)
A delegate of type E04HD_H.
- x
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: , for must contain the coordinates of a suitable point at which to check the derivatives calculated by funct. ‘Obvious’ settings, such as , should not be used since, at such particular points, incorrect terms may take correct values (particularly zero), so that errors could go undetected. Similarly, it is advisable that no two elements of x should be the same.
- g
- Type: array<System..::..Double>[]()[][]An array of size [n]
- hesl
- Type: array<System..::..Double>[]()[][]An array of size [lh]
- hesd
- Type: array<System..::..Double>[]()[][]An array of size [n]
- 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 function of the variables may require you to provide a method to evaluate the second derivatives of . e04hd is designed to check the second derivatives calculated by such user-supplied delegates. As well as the method to be checked (h), you must supply a method (funct) to evaluate the first derivatives, and a point at which the checks will be made. Note that e04hd checks methods of the form required for e04lb.
e04hd first calls user-supplied delegates funct and h to evaluate the first and second derivatives of at . The user-supplied Hessian matrix (, say) is 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 vector of first derivatives 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: e04hd 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
(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 second derivatives of , because it is very unlikely that h 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 as defined in [Description].
Parallelism and Performance
None.