# A combined automatic differentiation and array library for C++

## Automatic differentiation features

Adept enables C++ algorithms to be automatically differentiated. For each mathematical statement involving scalars or arrays of a special "active" type, Adept stores the corresponding differential statement symbolically on a stack. The stack may then be used to perform the following computations:

• Full Jacobian matrix. Given the non-linear function y=f(x) coded in C or C++, Adept will compute the matrix H=∂y/x, where the element at row i and column j of H is Hi,j=∂yi/∂xj. This matrix will be computed much more rapidly and accurately than if you simply recompute the function multiple times perturbing each element of x one by one. The Jacobian matrix is used in the Gauss-Newton and Levenberg-Marquardt minimization algorithms.
• Reverse-mode differentiation. This is a key component in optimization problems where a non-linear function needs to be minimized but the state vector x is too large for it to make sense to compute the full Jacobian matrix. Atmospheric data assimilation is the canonical example in Meteorology. Given a non-linear function y=f(x) and a vector of adjoints ∂J/∂y (where J is the scalar function to be minimized), Adept will compute the vector of adjoints ∂J/∂x. Formally, ∂J/∂x is given by the matrix-vector product HTJ/∂y, but it is computed here without computing the full Jacobian matrix H. The adjoint may then be used in a quasi-Newton minimization scheme.
• Forward-mode differentiation. Given the non-linear function y=f(x) and a vector of perturbations δx, Adept will compute the corresponding vector δy arising from a linearization of the function f. Formally, δy is given by the matrix-vector product Hδx, but it is computed here without computing the full Jacobian matrix H. Note that Adept is optimized for the reverse case, so might not be as fast (and will certainly not be as economical in memory) in the forward mode as libraries written especially for that purpose.
For full details of how to use Adept's automatic differentiation features, please consult Chapter 2 of the User Guide.