Personal tools

Automatic Differentiation

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(One intermediate revision by one user not shown)
Line 16: Line 16:
* [ ad] (forward, reverse and other modes)
* [ ad] (forward, forward w/ tower, reverse and other modes)
* [ fad] (forward mode)
* [ fad] (forward mode tower)
* [ rad] (reverse mode)
* [ rad] (reverse mode)
* [[Vector-space]] (forward mode)
* [[Vector-space]] (forward mode tower)
* (forward mode)
* [ Data.Ring.Module.AutomaticDifferentiation](forward mode)
== Power Series ==
== Power Series ==

Revision as of 21:40, 12 May 2011

Automatic Differentiation enables you to compute both the value of a function at a point and its derivative(s) at the same time.

When using Forward Mode this roughly means that a numerical value is equipped with its derivative with respect to one of your input, which is updated accordingly on every function application. Let the number x0 be equipped with the derivative x1: \langle x_0,x_1 \rangle. For example the sinus is defined as:

  • \sin\langle x_0,x_1 \rangle = \langle \sin x_0, x_1\cdot\cos x_0\rangle

Replacing this single derivative with a lazy list of them can enable you to compute an entire derivative tower at the same time.

However, it becomes more difficult for vector functions, when computing the derivatives in reverse, when computing towers, and/or when trying to minimize the number of computations needed to compute all of the kth partial derivatives of an n-ary function.

Forward mode is suitable when you have fewer arguments than outputs, because it requires multiple applications of the function, one for each input.

Reverse mode is suitable when you have fewer results than inputs, because it requires multiple applications of the function, one for each output.


1 Power Series

If you can compute all of the derivatives of a function, you can compute Taylor series from it.

Implementation with Haskell 98 type classes:

With advanced type classes in Numeric Prelude:

2 See also