NAG FL Interface
c05zdf (sys_​deriv_​check)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

c05zdf 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.

2 Specification

Fortran Interface
Subroutine c05zdf ( mode, m, n, x, fvec, fjac, xp, fvecp, err, ifail)
Integer, Intent (In) :: mode, m, n
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: x(n), fvec(m), fjac(m,n), fvecp(m)
Real (Kind=nag_wp), Intent (Out) :: xp(n), err(m)
C Header Interface
#include <nag.h>
void  c05zdf_ (const Integer *mode, const Integer *m, const Integer *n, const double x[], const double fvec[], const double fjac[], double xp[], const double fvecp[], double err[], Integer *ifail)
The routine may be called by the names c05zdf or nagf_roots_sys_deriv_check.

3 Description

c05zdf is based on the MINPACK routine CHKDER (see Moré et al. (1980)). It checks the ith gradient for consistency with the ith 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 c05zdf is its invariance under changes in scale of the variables or functions.

4 References

Moré J J, Garbow B S and Hillstrom K E (1980) User guide for MINPACK-1 Technical Report ANL-80-74 Argonne National Laboratory

5 Arguments

1: mode Integer Input
On entry: the value 1 on the first call and the value 2 on the second call of c05zdf.
Constraint: mode=1 or 2.
2: m Integer Input
On entry: m, the number of functions.
Constraint: m1.
3: n Integer Input
On entry: n, the number of variables. For use with c05rbf, c05rcf and c05rdf, m=n.
Constraint: n1.
4: x(n) Real (Kind=nag_wp) array Input
On entry: the components of a point x, at which the consistency check is to be made. (See Section 7.)
5: fvec(m) Real (Kind=nag_wp) array Input
On entry: if mode=2, fvec must contain the value of the functions evaluated at x. If mode=1, fvec is not referenced.
6: fjac(m,n) Real (Kind=nag_wp) array Input
On entry: if mode=2, fjac must contain the value of fi xj at the point x, for i=1,2,,m and j=1,2,,n. If mode=1, fjac is not referenced.
7: xp(n) Real (Kind=nag_wp) array Output
On exit: if mode=1, xp is set to a point neighbouring x. If mode=2, xp is undefined.
8: fvecp(m) Real (Kind=nag_wp) array Input
On entry: if mode=2, fvecp must contain the value of the functions evaluated at xp (as output by a preceding call to c05zdf with mode=1). If mode=1, fvecp is not referenced.
9: err(m) Real (Kind=nag_wp) array Output
On exit: if mode=2, err contains measures of correctness of the respective gradients. If mode=1, err is undefined. If there is no loss of significance (see Section 7), if err(i) is 1.0 the ith user-supplied gradient fi xj , for j=1,2,,n is correct, whilst if err(i) is 0.0 the ith gradient is incorrect. For values of err(i) between 0.0 and 1.0 the categorisation is less certain. In general, a value of err(i)>0.5 indicates that the ith gradient is probably correct.
10: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of -1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value -1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, mode=value.
Constraint: mode=1 or 2.
ifail=2
On entry, m=value.
Constraint: m1.
ifail=3
On entry, n=value.
Constraint: n1.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

c05zdf 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 x 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 and fvec should be at least two orders of magnitude greater than the machine precision returned by x02ajf.

8 Parallelism and Performance

c05zdf is not threaded in any implementation.

9 Further Comments

The time required by c05zdf increases with m and n.

10 Example

This example checks the Jacobian matrix for a problem with 15 functions of 3 variables (sometimes referred to as the Bard problem).

10.1 Program Text

Program Text (c05zdfe.f90)

10.2 Program Data

None.

10.3 Program Results

Program Results (c05zdfe.r)