FDJAC
Approximates the Jacobian of M functions in N unknowns using forward differences.
Required Arguments
FCN — User-supplied subroutine to evaluate the function to be minimized. The usage is
CALL FCN (M, N, X, F), where
M – Length of F. (Input)
N – Length of X. (Input)
X – The point at which the function is evaluated. (Input)
X should not be changed by FCN.
F – The computed function at the point X. (Output)
FCN must be declared EXTERNAL in the calling program.
XC — Vector of length N containing the point at which the gradient is to be estimated. (Input)
FC — Vector of length M containing the function values at XC. (Input)
FJACM by N matrix containing the estimated Jacobian at XC. (Output)
Optional Arguments
M — The number of functions. (Input)
Default: M = SIZE (FC,1).
N — The number of variables. (Input)
Default: N = SIZE (XC,1).
XSCALE — Vector of length N containing the diagonal scaling matrix for the variables. (Input)
In the absence of other information, set all entries to 1.0.
Default: XSCALE = 1.0.
EPSFCN — Estimate for the relative noise in the function. (Input)
EPSFCN must be less than or equal to 0.1. In the absence of other information, set EPSFCN to 0.0.
Default: EPSFCN = 0.0.
LDFJAC — Leading dimension of FJAC exactly as specified in the dimension statement of the calling program. (Input)
Default: LDFJAC = SIZE (FJAC,1).
FORTRAN 90 Interface
Generic: CALL FDJAC (FCN, XC, FC, FJAC [])
Specific: The specific interface names are S_FDJAC and D_FDJAC.
FORTRAN 77 Interface
Single: CALL FDJAC (FCN, M, N, XC, XSCALE, FC, EPSFCN, FJAC, LDFJAC)
Double: The double precision name is DFDJAC.
Description
The routine FDJAC uses the following finite-difference formula to estimate the Jacobian matrix of function f at x:
where ej is the j-th unit vector, hj = ɛ1/2 max{xj, 1/sj} sign(xj), ɛ is the machine epsilon, and sj is the scaling factor of the j-th variable. For more details, see Dennis and Schnabel (1983).
Since the finite-difference method has truncation error, cancellation error, and rounding error, users should be aware of possible poor performance. When possible, high precision arithmetic is recommended.
Comments
1. Workspace may be explicitly provided, if desired, by use of F2JAC/DF2JAC. The reference is:
CALL F2JAC (FCN, M, N, XC, XSCALE, FC, EPSFCN, FJAC, LDFJAC, WK)
The additional argument is:
WK — Work vector of length M.
2. This is Description A5.4.1, Dennis and Schnabel, 1983, page 314.
Example
In this example, the Jacobian matrix of
is estimated by the finite-difference method at the point (1.0, 1.0).
 
USE FDJAC_INT
USE UMACH_INT
 
IMPLICIT NONE
! Declaration of variables
INTEGER N, M, LDFJAC, NOUT
PARAMETER (N=2, M=2, LDFJAC=2)
REAL FJAC(LDFJAC,N), XC(N), FC(M), EPSFCN
EXTERNAL FCN!
DATA XC/2*1.0E0/
! Set function noise
EPSFCN = 0.01
! Evaluate the function at the
! current point
CALL FCN (M, N, XC, FC)
! Get Jacobian forward-difference
! approximation
CALL FDJAC (FCN, XC, FC, FJAC, EPSFCN=EPFSCN)
! Print results
CALL UMACH (2, NOUT)
WRITE (NOUT,99999) ((FJAC(I,J),J=1,N),I=1,M)
99999 FORMAT (’ The Jacobian is’, /, 2(5X,2F10.2,/),/)
!
END
!
SUBROUTINE FCN (M, N, X, F)
! SPECIFICATIONS FOR ARGUMENTS
INTEGER M, N
REAL X(N), F(M)
!
F(1) = X(1)*X(2) - 2.0E0
F(2) = X(1) - X(1)*X(2) + 1.0E0
!
RETURN
END
Output
 
The Jacobian is
1.00 1.00
0.00 -1.00
Published date: 03/19/2020
Last modified date: 03/19/2020