NAG CL Interface
c05zdc (sys_​deriv_​check)

Settings help

CL Name Style:

1 Purpose

c05zdc checks the user-supplied gradients of a set of nonlinear functions in several variables, for consistency with the functions themselves. The function must be called twice.

2 Specification

#include <nag.h>
void  c05zdc (Integer mode, Integer m, Integer n, const double x[], const double fvec[], const double fjac[], double xp[], const double fvecp[], double err[], NagError *fail)
The function may be called by the names: c05zdc, nag_roots_sys_deriv_check or nag_check_derivs.

3 Description

c05zdc 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 c05zdc 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 c05zdc.
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 c05rbc, c05rcc and c05rdc, m=n.
Constraint: n1.
4: x[n] const double Input
On entry: the components of a point x, at which the consistency check is to be made. (See Section 7.)
5: fvec[m] const double 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] const double Input
Note: the (i,j)th element of the matrix is stored in fjac[(j-1)×m+i-1].
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] double Output
On exit: if mode=1, xp is set to a point neighbouring x. If mode=2, xp is undefined.
8: fvecp[m] const double Input
On entry: if mode=2, fvecp must contain the value of the functions evaluated at xp (as output by a preceding call to c05zdc with mode=1). If mode=1, fvecp is not referenced.
9: err[m] double 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-1] is 1.0 the ith user-supplied gradient fi xj , for j=1,2,,n is correct, whilst if err[i-1] is 0.0 the ith gradient is incorrect. For values of err[i-1] between 0.0 and 1.0 the categorisation is less certain. In general, a value of err[i-1]>0.5 indicates that the ith gradient is probably correct.
10: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument value had an illegal value.
On entry, m=value.
Constraint: m1.
On entry, mode=value.
Constraint: mode=1 or 2.
On entry, n=value.
Constraint: n1.
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

7 Accuracy

c05zdc 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 X02AJC.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
c05zdc is not threaded in any implementation.

9 Further Comments

The time required by c05zdc 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 (c05zdce.c)

10.2 Program Data


10.3 Program Results

Program Results (c05zdce.r)