Differentiation tools in Julia. JuliaDiff on GitHub.

Stop approximating derivatives!

Derivatives are required at the core of many numerical algorithms. Unfortunately, they are usually computed inefficiently and approximately by some variant of the finite difference approach $$ f'(x) \approx \frac{f(x+h) - f(x)}{h}, h \text{ small }. $$ This method is inefficient because it requires \( \Omega(n) \) evaluations of \( f : \mathbb{R}^n \to \mathbb{R} \) to compute the gradient \( \nabla f(x) = \left( \frac{\partial f}{\partial x_1}(x), \cdots, \frac{\partial f}{\partial x_n}(x)\right) \), for example. It is approximate because we have to choose some finite, small value of the step length \( h \), balancing floating-point precision with mathematical approximation error.

What can we do instead?

One option is to explicitly write down a function which computes the exact derivatives by using the rules that we know from Calculus. However, this quickly becomes an error-prone and tedious exercise. There is another way! The field of automatic differentiation provides methods for automatically computing exact derivatives (up to floating-point error) given only the function \( f \) itself. Some methods use many fewer evaluations of \( f \) than would be required when using finite differences. In the best case, the exact gradient of \( f \) can be evaluated for the cost of \( O(1) \) evaluations of \( f \) itself. The caveat is that \( f \) cannot be considered a black box; instead, we require either access to the source code of \( f \) or a way to plug in a special type of number using operator overloading.

What is JuliaDiff?

JuliaDiff is an informal organization which aims to unify and document packages written in Julia for evaluating derivatives. The technical features of Julia, namely, multiple dispatch, source code via reflection, JIT compilation, and first-class access to expression parsing make implementing and using techniques from automatic differentiation easier than ever before (in our biased opinion). Packages hosted under the JuliaDiff organization follow the same guidelines as for JuliaOpt; namely, they should be actively maintained, well documented and have a basic testing suite.

Included packages

Below we list the packages that are currently included in the JuliaDiff organization and their testing status on the latest Julia release, if available.

Release testing status
ForwardDiff provides user-friendly methods for performing forward-mode automatic differentiation on native Julia code. ForwardDiff offers several advanced features, such as nested differentiation, a non-allocating API, and a SIMD-vectorizable multidimensional dual number type.
Release testing status
ReverseDiff provides user-friendly methods for performing reverse-mode automatic differentiation on native Julia code. ReverseDiff implements many linear algebra optimizations, flexible performance annotations, and composes well with ForwardDiff (enabling mixed-mode AD).
Release testing status
TaylorSeries implements truncated multivariate power series for high-order integration of ODEs and forward-mode automatic differentiation of arbitrary order derivatives via operator overloading.
Release testing status
DualNumbers provides a dual number type which can be used to take first-order scalar derivatives of native Julia code.
Release testing status
HyperDualNumbers provides a hyper-dual number type which can be used to take first-order and second-order scalar derivatives of native Julia code.

Related packages

These Julia packages also provide differentiation functionalities.

Release testing status
Fast reverse mode differentiation for scalar and tensor functions using source code transformation.
Release testing status
Provides methods for symbolic differentiation and finite-difference approximations.
Release testing status
An algebraic modeling language for optimization with an internal implementation of reverse-mode automatic differentiation for gradients and sparse Hessian matrices given closed-form expressions. Includes support for automatic differentiation of user-provided functions.
Release testing status
Implements truncated power series type which can be used for forward-mode automatic differentiation of arbitrary order derivatives via operator overloading.
Release testing status
Implements symbolic differentiation.

How are they being used?

Packages implementing automatic differentiation techniques are already in use in the broader Julia ecosystem:


Discussions on JuliaDiff and its uses may be directed to the Julia Discourse forum or the julia-opt mailing list. The site autodiff.org serves as a portal for the academic community. For a well-written simple introduction to reverse-mode automatic differentiation, see Justin Domke's blog post. Finally, automatic differentiation techniques have been implemented in a variety of languages. If you would prefer not to use Julia, see the wikipedia page for a comprehensive list of available packages.

This website was made with Skeleton, based on Iain Dunning's work on JuliaOpt. Something wrong? Submit issue. Contact: Miles Lubin (mlubin AT mit DOT edu)