Checks a user-supplied Hessian of an analytic function.
Required Arguments
GRAD — User-supplied subroutine to compute the gradient at the point X. The usage is CALLGRAD (N, X, G), where
N – Length of X and G. (Input)
X – The point at which the gradient is evaluated. X should not be changed by GRAD. (Input)
G – The gradient evaluated at the point X. (Output)
GRAD must be declared EXTERNAL in the calling program.
HESS — User-supplied subroutine to compute the Hessian at the point X. The usage is CALLHESS (N, X, H, LDH), where
N – Length of X. (Input)
X – The point at which the Hessian is evaluated. (Input) X should not be changed by HESS.
H – The Hessian evaluated at the point X. (Output)
LDH – Leading dimension of H exactly as specified in in the dimension statement of the calling program. (Input)
HESS must be declared EXTERNAL in the calling program.
X — Vector of length N containing the point at which the Hessian is to be checked. (Input)
INFO — Integer matrix of dimension N by N. (Output)
INFO(I, J) = 0 means the Hessian is a poor estimate for function I at the point X(J).
INFO(I, J) = 1 means the Hessian is a good estimate for function I at the point X(J).
INFO(I, J) = 2 means the Hessian disagrees with the numerical Hessian for function I at the point X(J), but it might be impossible to calculate the numerical Hessian.
INFO(I, J) = 3 means the Hessian for function I at the point X(J) and the numerical Hessian are both zero, and, therefore, the gradient should be rechecked at a different point.
Optional Arguments
N — Dimension of the problem. (Input) Default: N = SIZE (X,1).
LDINFO — Leading dimension of INFO exactly as specified in the dimension statement of the calling program. (Input) Default: LDINFO = SIZE (INFO,1).
FORTRAN 90 Interface
Generic: CALLCHHES (GRAD, HESS, X, INFO[, …])
Specific: The specific interface names are S_CHHES and D_CHHES.
FORTRAN 77 Interface
Single: CALLCHHES (GRAD, HESS, N, X, INFO, LDINFO)
Double: The double precision name is DCHHES.
Description
The routine CHHES uses the following finite-difference formula to estimate the Hessian of a function of n variables at x:
where
hj = ɛ1/2max{∣xj∣, 1/sj} sign(xj),
ɛ is the machine epsilon,
ej
is the j-th unit vector,
sj
is the scaling factor of the j-th variable, and
gi(x)
is the gradient of the function with respect to the i-th variable.
Next, CHHES checks the user-supplied Hessian H(x) by comparing it with the finite difference approximation B(x). If
∣Bij(x)‑Hij(x)∣ < ∣Hij(x)∣
where
= ɛ1/4,
then
Hij(x)
is declared correct; otherwise, CHHES computes the bounds of calculation error and approximation error. When both bounds are too small to account for the difference,
Hij(x)
is reported as incorrect. In the case of a large error bound, CHHES uses a nearly optimal stepsize to recompute
Bij(x)
and reports that
Bij(x)
is correct if
∣Bij(x)‑Hij(x)∣ < 2 ∣Hij(x)∣
Otherwise, Hij(x) is considered incorrect unless the error bound for the optimal step is greater than ∣Hij(x)∣. In this case, the numeric approximation may be impossible to compute correctly. For more details, see Schnabel (1985).
Comments
Workspace may be explicitly provided, if desired, by use of C2HES/DC2HES. The reference is