Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Brief description

NumDiff provides a modern Fortran interface for computing the Jacobian (derivative) matrix of m nonlinear functions which depend on n variables. The Jacobian matrix is required for various applications, including numerical optimization. The library also provides for computing the sparsity of this matrix, and returning the Jacobian in sparse or dense form.


CI Status

This is currently an experimental work in progress and is not production ready. The goal is a comprehensive library that contains a full suite of computationally efficient implementations of algorithms for sparsity determination and numerical differentiation. This code is hosted on GitHub at:

To Do

  • Computing the nonlinear sparsity pattern
    • Specified by the user
    • Assume all elements true
    • Three random points within variable bounds (have the option to specify separate bounds for this purpose)
  • Various order finite different gradient methods
    • 2-point (backward 1, forward 1)
    • 3-point (backward 2, central, forward 2)
    • 4-point (backward 3, backward 2, forward 2, forward 3)
    • 5-point (backward 4, backward 3, central, forward 3, forward 4)
    • 6-point (backward 5, backward 4, backward 3, forward 3, forward 4, forward 5)
    • 7-point (backward 6, backward 5, backward 4, central, forward 4, forward 5, forward 6)
    • 8-point (backward 7, backward 6, backward 5, backward 4, forward 4, forward 5, forward 6, forward 7)
    • 9-point (backward 8, backward 7, backward 6, backward 5, central, forward 5, forward 6, forward 7, forward 8)
    • 11-point (central)
    • 13-point (central)
    • 15-point (central)
    • 17-point (central)
  • Perturbations should respect variable bounds
  • Neville's process
  • Ability to use different methods for different columns
  • Jacobian partitioning to compute multiple columns at the same time
  • Estimate the optimal perturbation step size
  • Computing the linear sparsity pattern (constant elements of Jacobian)
  • Add other gradient methods?
  • Also compute Hessian matrix?
  • OpenMP or Coarrays for parallelization
  • Testing for computational efficiency
  • General code cleanup

Building NumDiff

A FoBiS configuration file (numdiff.fobis) is also provided that can also build the library and examples. Use the mode flag to indicate what to build. For example:

  • To build all the examples using gfortran: build -f numdiff.fobis -mode tests-gnu
  • To build all the examples using ifort: build -f numdiff.fobis -mode tests-intel
  • To build a static library using gfortran: build -f numdiff.fobis -mode static-gnu
  • To build a static library using ifort: build -f numdiff.fobis -mode static-intel

The full set of modes are: static-gnu, static-gnu-debug, static-intel, static-intel-debug, shared-gnu, shared-gnu-debug, shared-intel, shared-intel-debug, tests-gnu, tests-gnu-debug, tests-intel, tests-intel-debug

To generate the documentation using ford, run: rule --execute makedoc -f numdiff.fobis

To run the test programs, run: rule --execute tests -f numdiff.fobis


The latest API documentation can be found here. This was generated from the source code using FORD (note that the included script will also generate these files).


The NumDiff source code and related files and documentation are distributed under a permissive free software license (BSD-style).


  • J. Oliver, "An algorithm for numerical differentiation of a function of one real variable", Journal of Computational and Applied Mathematics 6 (2) (1980) 145–160. Fortran 77 code from NIST
  • Thomas F. Coleman, Burton S. Garbow, Jorge J. More, "Algorithm 618: FORTRAN subroutines for estimating sparse Jacobian Matrices", ACM Transactions on Mathematical Software (TOMS), Volume 10 Issue 3, Sept. 1984, Pages 346-347