NAG Library Routine Document
C05ZAF checks the user-supplied gradients of a set of nonlinear functions in several variables, for consistency with the functions themselves. The routine must be called twice.
||M, N, LDFJAC, MODE
||X(N), FVEC(M), FJAC(LDFJAC,N), XP(*), FVECP(M), ERR(*)
C05ZAF is based on the MINPACK routine CHKDER (see Moré et al. (1980)
). It checks the
th gradient for consistency with the
th function by computing a forward-difference approximation along a suitably chosen direction and comparing this approximation with the user-supplied gradient along the same direction. The principal characteristic of C05ZAF is its invariance under changes in scale of the variables or functions.
Moré J J, Garbow B S and Hillstrom K E (1980) User guide for MINPACK-1 Technical Report ANL-80-74 Argonne National Laboratory
- 1: M – INTEGERInput
On entry: the number of functions.
- 2: N – INTEGERInput
: the number of variables. For use with C05PBF/C05PBA
- 3: X(N) – REAL (KIND=nag_wp) arrayInput
: the components of a point
, at which the consistency check is to be made. (See Section 8
- 4: FVEC(M) – REAL (KIND=nag_wp) arrayInput
must contain the functions evaluated at
- 5: FJAC(LDFJAC,N) – REAL (KIND=nag_wp) arrayInput
must contain the user-supplied gradients. (The
th row of FJAC
must contain the gradient of the
th function evaluated at the point
- 6: LDFJAC – INTEGERInput
: the first dimension of the array FJAC
as declared in the (sub)program from which C05ZAF is called.
- 7: XP() – REAL (KIND=nag_wp) arrayOutput
the dimension of the array XP
must be at least
, and at least
is set to a neighbouring point to X
- 8: FVECP(M) – REAL (KIND=nag_wp) arrayInput
must contain the functions evaluated at XP
- 9: MODE – INTEGERInput
On entry: the value on the first call and the value on the second call of C05ZAF.
- 10: ERR() – REAL (KIND=nag_wp) arrayOutput
the dimension of the array ERR
must be at least
, and at least
contains measures of correctness of the respective gradients. If there is no loss of significance (see Section 8
), then if
th user-supplied gradient is correct, whilst if
th gradient is incorrect. For values of
the categorisation is less certain. In general, a value of
indicates that the
th gradient is probably correct.
6 Error Indicators and Warnings
If an error is detected in an input parameter C05ZAF will act as if a soft noisy exit has been requested (see Section 3.3.4
in the Essential Introduction).
The time required by C05ZAF increases with M
C05ZAF does not perform reliably if cancellation or rounding errors cause a severe loss of significance in the evaluation of a function. Therefore, none of the components of
should be unusually small (in particular, zero) or any other value which may cause loss of significance. The relative differences between corresponding elements of FVECP
should be at least two orders of magnitude greater than the machine precision
This example checks the Jacobian matrix for a problem with functions of variables (sometimes referred to as the Bard problem).
9.1 Program Text
Program Text (c05zafe.f90)
9.2 Program Data
9.3 Program Results
Program Results (c05zafe.r)