An introduction to using software tools for automatic differentiation.

Uwe Naumann, Andrea Walther

Introduction

In scientific computing, the need for accurate derivatives of complex functions is ubiquitous, appearing in optimization, sensitivity analysis, and the solution of differential equations. Traditionally, researchers faced a choice between tedious, error-prone manual derivations or numerically unstable finite difference approximations.

Automatic Differentiation (AD) provides a robust alternative, systematically applying the chain rule to computer programs to generate derivative code accurate to machine precision. This technical memorandum serves as a practical guide for utilizing four major AD tools: ADIFOR, ADIC, ADOL-C, and TAPENADE.

Methodologies: Source Transformation vs. Operator Overloading

The AD landscape is primarily divided into two paradigms:

  1. Source Transformation: Tools like ADIFOR 2.0, TAPENADE (for Fortran), and ADIC 1.1 (for C) act as pre-compilers. They analyze the original source code and generate new source code that explicitly calculates derivatives.
  2. Operator Overloading: ADOL-C utilizes C++ features to "tape" or record mathematical operations during program execution. This tape is subsequently replayed to compute derivatives in forward or reverse modes.

Handling Sparsity and the Seeding Strategy

For large-scale systems, Jacobians are typically sparse. Storing and computing every entry is computationally prohibitive. A key insight discussed is the use of "seeding" based on graph coloring algorithms, such as the Curtis-Powell-Reid algorithm. By representing the dependency structure of the variables as a graph, researchers can identify independent columns that can be computed simultaneously in a single pass.

Dependency graph for a 9-variable system used to determine independent columns for compressed Jacobian computation.

This approach allows for the computation of compressed Jacobians, drastically reducing memory and processing time. By viewing the Jacobian as a graph coloring problem, multiple independent columns can be grouped, provided they do not share non-zero rows.

The Explosion Equation Benchmark

To demonstrate these tools, the authors utilize the "Explosion Equation," a variant of the Bratu problem modeling thermal explosions in solid fuels. Discretized into a system of 10,000 equations, this benchmark provides a realistic test for handling large-scale, sparse Jacobians. The scale of this problem proves the tools' ability to manage high-dimensional data without the overhead of storing millions of zero entries.

Tool-Specific Implementation

While the mathematical foundation remains consistent, implementation details vary significantly across the software suite:

  • ADOL-C requires changing variable types to adouble to enable its operator overloading mechanism.
  • ADIFOR utilizes composition files and specialized drivers to manage the source transformation process.
  • TAPENADE, while in an alpha state during the study, demonstrated the power of the reverse (adjoint) mode. This mode is computationally superior for problems with many inputs and a single output, such as cost function optimization.

Key Results and Accuracy

All evaluated tools successfully produced Jacobians accurate to machine precision, effectively bypassing the "step-size dilemma" inherent in finite difference methods.

Sample Jacobian matrix output showing the sparsity pattern and machine-precision numerical values.

Through the integration of specialized libraries like SparsLinC, the 10,000-variable problem was handled efficiently. The results demonstrate that AD can produce high-fidelity derivatives while maintaining computational efficiency through compressed seeding.

Conclusion

The study proves that AD tools can be integrated into existing build environments with manageable overhead. While manual setup and language constraints (Fortran vs. C/C++) were notable hurdles at the time, the accuracy and efficiency gains make AD an essential tool for modern scientific software development. As these tools continue to evolve, they move closer to becoming a "one-click" solution for complex derivative calculations.

Summary updated

BibTeX
@misc{naumann2003introduction,
  author = {Uwe Naumann and Andrea Walther},
  title = {{An introduction to using software tools for automatic differentiation.}},
  year = {2003},
  eprint = {cs/0310057},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/cs/0310057},
}
Figure