Forward Automatic Differentiation. http://github.com/bjornbm/fad
|Latest on Hackage:||126.96.36.199|
This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.
License : BSD3
Maintainer : firstname.lastname@example.org
Stability : experimental
Portability: GHC only?
Forward Automatic Differentiation via overloading to perform
nonstandard interpretation that replaces original numeric type with
corresponding generalized dual number type.
Each invocation of the differentiation function introduces a
distinct perturbation, which requires a distinct dual number type.
In order to prevent these from being confused, tagging, called
branding in the Haskell community, is used. This seems to prevent
perturbation confusion, although it would be nice to have an actual
proof of this. The technique does require adding invocations of
lift at appropriate places when nesting is present.
For more information on perturbation confusion and the solution
employed in this library see:
runhaskell Setup.lhs configure
runhaskell Setup.lhs build
runhaskell Setup.lhs install
Define an example function 'f':
> import Numeric.FAD
> f x = 6 - 5 * x + x ^ 2 -- Our example function
Basic usage of the differentiation operator:
> y = f 2 -- f(2) = 0
> y' = diff f 2 -- First derivative f'(2) = -1
> y'' = diff (diff f) 2 -- Second derivative f''(2) = 2
List of derivatives:
> ys = take 3 $ diffs f 2 -- [0, -1, 2]
Example optimization method; find a zero using Newton's method:
> y_newton1 = zeroNewton f 0 -- converges to first zero at 2.0.
> y_newton2 = zeroNewton f 10 -- converges to second zero at 3.0.
Authors: Copyright 2008,
Barak A. Pearlmutter <email@example.com> &
Jeffrey Mark Siskind <firstname.lastname@example.org>
Work started as stripped-down version of higher-order tower code
published by Jerzy Karczmarczuk <email@example.com>
which used a non-standard standard prelude.
Initial perturbation-confusing code is a modified version of
Tag trick, called "branding" in the Haskell community, from
Bjorn Buckwalter <firstname.lastname@example.org>