e04hd checks that a method for calculating second derivatives of an objective function is consistent with a method for calculating the corresponding first derivatives.
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 )
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 _ )
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 )
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
- Type: System..::..Int32On entry: the number of independent variables in the objective function.Constraint: .
- 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.
- 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.
- Type: array<System..::..Double>()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.
- Type: array<System..::..Double>()
- Type: array<System..::..Double>()
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.
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.