Math 2.0

Numerical analysis Definition

Automatic differentiation

Builds on DerivativePartial derivativeJacobian matrix

Definition

Let U⊆ℝnU \subseteq \R^n be open and let f ⁣:U→ℝmf \colon U \to \R^m be given by an evaluation trace. Its first variables v1−n,…,v0v_{1-n}, \ldots, v_0 are the inputs x1,…,xnx_1, \ldots, x_n. The others are given for k=1,…,ℓk = 1, \ldots, \ell by vk=φk((vj)j∈Pk),v_k = \varphi_k\big( (v_j)_{j \in P_k} \big), where Pk⊆{1−n,…,k−1}P_k \subseteq \set{1 - n, \ldots, k - 1} and each φk\varphi_k is a differentiable elementary function, such as ++, ×\times, sin⁡\sin or exp⁡\exp. The outputs y1,…,ymy_1, \ldots, y_m are some of the vkv_k.

  1. Forward mode takes a direction x˙∈ℝn\dot x \in \R^n, sets v˙i−n=x˙i\dot v_{i - n} = \dot x_i, and computes along with each vkv_k the value v˙k=∑j∈Pk∂φk∂vjv˙j\dot v_k = \sum_{j \in P_k} \frac{\partial \varphi_k}{\partial v_j} \dot v_j.
  2. Reverse mode first evaluates the trace and takes yˉ∈ℝm\bar y \in \R^m. It sets the adjoint vˉ\bar v of each output to its entry of yˉ\bar y and all other adjoints to 00. Then for k=ℓ,ℓ−1,…,1k = \ell, \ell - 1, \ldots, 1 it adds vˉk∂φk∂vj\bar v_k \frac{\partial \varphi_k}{\partial v_j} to vˉj\bar v_j for each j∈Pkj \in P_k.

Automatic differentiation is the computation of derivatives of ff by these propagation rules. Forward mode returns y˙=Jf(x)x˙\dot y = J_f(x) \dot x, where Jf(x)J_f(x) is the Jacobian matrix. Reverse mode returns xˉ=Jf(x)Tyˉ\bar x = J_f(x)^{T} \bar y, where xˉi=vˉi−n\bar x_i = \bar v_{i-n}.

Remarks

Example: f(x1,x2)=x1x2+sin⁡x1f(x_1, x_2) = x_1 x_2 + \sin x_1 has the trace v1=v−1v0v_1 = v_{-1} v_0, v2=sin⁡v−1v_2 = \sin v_{-1}, v3=v1+v2v_3 = v_1 + v_2. Forward mode at (x1,x2)=(1,2)(x_1, x_2) = (1, 2) with x˙=(1,0)\dot x = (1, 0) gives v˙1=2\dot v_1 = 2, v˙2=cos⁡1\dot v_2 = \cos 1, v˙3=2+cos⁡1\dot v_3 = 2 + \cos 1, which is the partial derivative ∂f/∂x1=x2+cos⁡x1\partial f / \partial x_1 = x_2 + \cos x_1 at (1,2)(1, 2). Reverse mode with yˉ=1\bar y = 1 gives vˉ1=vˉ2=1\bar v_1 = \bar v_2 = 1, then vˉ0=v−1=1\bar v_0 = v_{-1} = 1 and vˉ−1=v0+cos⁡v−1=2+cos⁡1\bar v_{-1} = v_0 + \cos v_{-1} = 2 + \cos 1, the full gradient in one backward sweep. Non-example: the difference quotient f(x+he1)−f(x)h\frac{f(x + h e_1) - f(x)}{h} is not automatic differentiation; it does not use the trace and has a truncation error of order hh. Forward mode can be described with dual numbers a+bεa + b\varepsilon, ε2=0\varepsilon^2 = 0: evaluating the program on x+x˙εx + \dot x \varepsilon gives f(x)+(Jf(x)x˙)εf(x) + (J_f(x) \dot x) \varepsilon.

Reading path

To understand this page from the ground up, read these 8 pages in order. The foundations come first.

Show the path as a graph
Each page uses the pages above it. The colour of the bar on a box shows how strong the evidence is, and the box also gives it as text. The list has the same pages.
  • no evidence level
  1. Derivative concept
  2. Euclidean space object
  3. Function concept
  4. Total derivative concept
  5. Function of several variables concept
  6. Partial derivative concept
  7. Jacobian matrix concept
  8. Automatic differentiation definition

Further reading

  1. Web https://en.wikipedia.org/wiki/Automatic_differentiation
About this page
TagKDZN92Z8JR
URIm2://KDZN92Z8JR
Kinddefinition
WritingW0 stub
MSC65D25, 68W30
DefinesAutomatic differentiation
UsesDerivative, Partial derivative, Jacobian matrix

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • an inventory row: the row of the inventory that the node accounts for (0 of 1)
  • a source with a locator (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

No page links to this page yet.