ad-4.4: Automatic Differentiation

Safe HaskellNone
LanguageHaskell2010

Numeric.AD.Rank1.Forward.Double

Contents

Synopsis

Documentation

data ForwardDouble Source #

Instances
Enum ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Eq ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Floating ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Fractional ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Num ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Ord ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Read ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Real ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

RealFloat ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

RealFrac ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Show ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Erf ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

InvErf ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Mode ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Associated Types

type Scalar ForwardDouble :: Type Source #

Jacobian ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Associated Types

type D ForwardDouble :: Type Source #

type Scalar ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

type D ForwardDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Forward.Double

Gradient

grad :: Traversable f => (f ForwardDouble -> ForwardDouble) -> f Double -> f Double Source #

Compute the gradient of a function using forward mode AD.

Note, this performs O(n) worse than grad for n inputs, in exchange for better space utilization.

grad' :: Traversable f => (f ForwardDouble -> ForwardDouble) -> f Double -> (Double, f Double) Source #

Compute the gradient and answer to a function using forward mode AD.

Note, this performs O(n) worse than grad' for n inputs, in exchange for better space utilization.

gradWith :: Traversable f => (Double -> Double -> b) -> (f ForwardDouble -> ForwardDouble) -> f Double -> f b Source #

Compute the gradient of a function using forward mode AD and combine the result with the input using a user-specified function.

Note, this performs O(n) worse than gradWith for n inputs, in exchange for better space utilization.

gradWith' :: Traversable f => (Double -> Double -> b) -> (f ForwardDouble -> ForwardDouble) -> f Double -> (Double, f b) Source #

Compute the gradient of a function using forward mode AD and the answer, and combine the result with the input using a user-specified function.

Note, this performs O(n) worse than gradWith' for n inputs, in exchange for better space utilization.

>>> gradWith' (,) sum [0..4]
(10.0,[(0.0,1.0),(1.0,1.0),(2.0,1.0),(3.0,1.0),(4.0,1.0)])

Jacobian

jacobian :: (Traversable f, Traversable g) => (f ForwardDouble -> g ForwardDouble) -> f Double -> g (f Double) Source #

Compute the Jacobian using Forward mode AD. This must transpose the result, so jacobianT is faster and allows more result types.

>>> jacobian (\[x,y] -> [y,x,x+y,x*y,exp x * sin y]) [pi,1]
[[0.0,1.0],[1.0,0.0],[1.0,1.0],[1.0,3.141592653589793],[19.472221418841606,12.502969588876512]]

jacobian' :: (Traversable f, Traversable g) => (f ForwardDouble -> g ForwardDouble) -> f Double -> g (Double, f Double) Source #

Compute the Jacobian using Forward mode AD along with the actual answer.

jacobianWith :: (Traversable f, Traversable g) => (Double -> Double -> b) -> (f ForwardDouble -> g ForwardDouble) -> f Double -> g (f b) Source #

Compute the Jacobian using Forward mode AD and combine the output with the input. This must transpose the result, so jacobianWithT is faster, and allows more result types.

jacobianWith' :: (Traversable f, Traversable g) => (Double -> Double -> b) -> (f ForwardDouble -> g ForwardDouble) -> f Double -> g (Double, f b) Source #

Compute the Jacobian using Forward mode AD combined with the input using a user specified function, along with the actual answer.

Transposed Jacobian

jacobianT :: (Traversable f, Functor g) => (f ForwardDouble -> g ForwardDouble) -> f Double -> f (g Double) Source #

A fast, simple, transposed Jacobian computed with forward-mode AD.

jacobianWithT :: (Traversable f, Functor g) => (Double -> Double -> b) -> (f ForwardDouble -> g ForwardDouble) -> f Double -> f (g b) Source #

A fast, simple, transposed Jacobian computed with Forward mode AD that combines the output with the input.

Derivatives

diff :: (ForwardDouble -> ForwardDouble) -> Double -> Double Source #

The diff function calculates the first derivative of a scalar-to-scalar function by forward-mode AD

>>> diff sin 0
1.0

diff' :: (ForwardDouble -> ForwardDouble) -> Double -> (Double, Double) Source #

The diff' function calculates the result and first derivative of scalar-to-scalar function by Forward mode AD

diff' sin == sin &&& cos
diff' f = f &&& d f
>>> diff' sin 0
(0.0,1.0)
>>> diff' exp 0
(1.0,1.0)

diffF :: Functor f => (ForwardDouble -> f ForwardDouble) -> Double -> f Double Source #

The diffF function calculates the first derivatives of scalar-to-nonscalar function by Forward mode AD

>>> diffF (\a -> [sin a, cos a]) 0
[1.0,-0.0]

diffF' :: Functor f => (ForwardDouble -> f ForwardDouble) -> Double -> f (Double, Double) Source #

The diffF' function calculates the result and first derivatives of a scalar-to-non-scalar function by Forward mode AD

>>> diffF' (\a -> [sin a, cos a]) 0
[(0.0,1.0),(1.0,-0.0)]

Directional Derivatives

du :: Functor f => (f ForwardDouble -> ForwardDouble) -> f (Double, Double) -> Double Source #

Compute the directional derivative of a function given a zipped up Functor of the input values and their derivatives

du' :: Functor f => (f ForwardDouble -> ForwardDouble) -> f (Double, Double) -> (Double, Double) Source #

Compute the answer and directional derivative of a function given a zipped up Functor of the input values and their derivatives

duF :: (Functor f, Functor g) => (f ForwardDouble -> g ForwardDouble) -> f (Double, Double) -> g Double Source #

Compute a vector of directional derivatives for a function given a zipped up Functor of the input values and their derivatives.

duF' :: (Functor f, Functor g) => (f ForwardDouble -> g ForwardDouble) -> f (Double, Double) -> g (Double, Double) Source #

Compute a vector of answers and directional derivatives for a function given a zipped up Functor of the input values and their derivatives.