In mathematics and computer algebra, automatic differentiation (auto-differentiation, autodiff, or AD), also called algorithmic differentiation, computational differentiation, and differentiation arithmetic is a set of techniques to evaluate the partial derivative of a function specified by a computer program. Automatic differentiation enables the simultaneous computation of the numerical values of arbitrarily complex functions and their derivatives using only the function itself; no symbolic derivative is required. Auto-differentiation is thus neither numeric nor symbolic, nor is it a combination of both. In contrast to the more traditional numerical methods based on finite differences, auto-differentiation is 'in theory' exact, and in comparison to symbolic algorithms, it is computationally inexpensive. Automatic differentiation exploits the fact that every computer calculation, no matter how complicated, executes a sequence of elementary arithmetic operations (addition, subtraction, multiplication, division, etc.) and elementary functions (exp, log, sin, cos, etc.). By applying the chain rule repeatedly to these operations, partial derivatives of arbitrary order can be computed automatically, accurately to working precision, and using at most a small constant factor of more arithmetic operations than the original program.
Difference from other differentiation methods
Automatic differentiation is distinct from symbolic differentiation and numerical differentiation. Symbolic differentiation faces the difficulty of converting a computer program into a single mathematical expression and can lead to inefficient code. Numerical differentiation (the method of finite differences) can introduce round-off errors in the discretization process and cancellation. These classical methods may have problems with calculating higher derivatives, where complexity and errors increase. Finally, both of these classical methods may be slow at computing partial derivatives of a function with respect to many inputs, as is needed for gradient-based optimization algorithms. Automatic differentiation solves all of these problems.
Applications Because of its efficiency and accuracy in computing first and higher order derivatives, auto-differentiation finds diverse applications in scientific computing and mathematics, and there are numerous computational implementations of auto-differentiation. Among these, one mentions INTLAB, Sollya, and InCLosure. In practice, there are two types (modes) of algorithmic differentiation: a forward-type and a reversed-type. Presently, the two types are highly correlated and complementary and both have a wide variety of applications in, e.g., non-linear optimization, sensitivity analysis, robotics, machine learning, computer graphics, and computer vision. Automatic differentiation is particularly important in the field of machine learning. For example, it allows one to implement backpropagation in a neural network without a manually-computed derivative.
Forward and reverse accumulation
Chain rule of partial derivatives of composite functions Fundamental to automatic differentiation is the decomposition of differentials provided by the chain rule of partial derivatives of composite functions. For the simple composition y=f(g(h(x)))=f(g(h(w0)))=f(g(w1))=f(w2)=w3w0=xw1=h(w0)w2=g(w1)w3=f(w2)=y the chain rule gives ∂y∂x=∂y∂w2∂w2∂w1∂w1∂x=∂f(w2)∂w2∂g(w1)∂w1∂h(w0)∂x
Two types of automatic differentiation Usually, two distinct modes of automatic differentiation are presented.
forward accumulation (also called bottom-up, forward mode, or tangent mode) reverse accumulation (also called top-down, reverse mode, or adjoint mode) Forward accumulation specifies that one traverses the chain rule from inside to outside (that is, first compute ∂w1∂x and then ∂w2∂w1 and lastly ∂y∂w2), while reverse accumulation traverses from outside to inside (first compute ∂y∂w2 and then ∂w2∂w1 and lastly ∂w1∂x). More succinctly,
Forward accumulation computes the recursive relation: ∂wi∂x=∂wi∂wi−1∂wi−1∂xwith w3=y, Reverse accumulation computes the recursive relation: ∂y∂wi=∂y∂wi+1∂wi+1∂wiwith w0=x. The value of the partial derivative, called the seed, is propagated forward or backward and is initially ∂x∂x=1 or ∂y∂y=1. Forward accumulation evaluates the function and calculates the derivative with respect to one independent variable in one pass. For each independent variable x1,x2,…,xn a separate pass is therefore necessary in which the derivative with respect to that independent variable is set to one (∂x1∂x1=1) and of all others to zero (∂x2∂x1=⋯=∂xn∂x1=0). In contrast, reverse accumulation requires the evaluated partial functions for the partial derivatives. Reverse accumulation therefore evaluates the function first and calculates the derivatives with respect to all independent variables in an additional pass. Which of these two types should be used depends on the sweep count. The computational complexity of one sweep is proportional to the complexity of the original code.
Forward accumulation is more efficient than reverse accumulation for functions f:ℝn→ℝm with n≪m as only n sweeps are necessary, compared to m sweeps for reverse accumulation. Reverse accumulation is more efficient than forward accumulation for functions f:ℝn→ℝm with n≫m as only m sweeps are necessary, compared to n sweeps for forward accumulation. Backpropagation of errors in multilayer perceptrons, a technique used in machine learning, is a special case of reverse accumulation. Forward accumulation was introduced by R. E. Wengert in 1964. According to Andreas Griewank, reverse accumulation has been suggested since the late 1960s, but the inventor is unknown. Seppo Linnainmaa published reverse accumulation in 1976.
Forward accumulation
… excerpt ends here. Continue reading the full article.





