Copyright | (c) Edward Kmett 2010-2015 |
---|---|

License | BSD3 |

Maintainer | ekmett@gmail.com |

Stability | experimental |

Portability | GHC only |

Safe Haskell | None |

Language | Haskell2010 |

Higher order derivatives via a "dual number tower".

## Synopsis

- data Tower a
- auto :: Mode t => Scalar t -> t
- taylor :: Fractional a => (Tower a -> Tower a) -> a -> a -> [a]
- taylor0 :: Fractional a => (Tower a -> Tower a) -> a -> a -> [a]
- maclaurin :: Fractional a => (Tower a -> Tower a) -> a -> [a]
- maclaurin0 :: Fractional a => (Tower a -> Tower a) -> a -> [a]
- diff :: Num a => (Tower a -> Tower a) -> a -> a
- diff' :: Num a => (Tower a -> Tower a) -> a -> (a, a)
- diffs :: Num a => (Tower a -> Tower a) -> a -> [a]
- diffs0 :: Num a => (Tower a -> Tower a) -> a -> [a]
- diffsF :: (Functor f, Num a) => (Tower a -> f (Tower a)) -> a -> f [a]
- diffs0F :: (Functor f, Num a) => (Tower a -> f (Tower a)) -> a -> f [a]
- du :: (Functor f, Num a) => (f (Tower a) -> Tower a) -> f (a, a) -> a
- du' :: (Functor f, Num a) => (f (Tower a) -> Tower a) -> f (a, a) -> (a, a)
- dus :: (Functor f, Num a) => (f (Tower a) -> Tower a) -> f [a] -> [a]
- dus0 :: (Functor f, Num a) => (f (Tower a) -> Tower a) -> f [a] -> [a]
- duF :: (Functor f, Functor g, Num a) => (f (Tower a) -> g (Tower a)) -> f (a, a) -> g a
- duF' :: (Functor f, Functor g, Num a) => (f (Tower a) -> g (Tower a)) -> f (a, a) -> g (a, a)
- dusF :: (Functor f, Functor g, Num a) => (f (Tower a) -> g (Tower a)) -> f [a] -> g [a]
- dus0F :: (Functor f, Functor g, Num a) => (f (Tower a) -> g (Tower a)) -> f [a] -> g [a]

# Documentation

`Tower`

is an AD `Mode`

that calculates a tangent tower by forward AD, and provides fast `diffsUU`

, `diffsUF`

## Instances

(Num a, Bounded a) => Bounded (Tower a) Source # | |

(Num a, Enum a) => Enum (Tower a) Source # | |

(Num a, Eq a) => Eq (Tower a) Source # | |

Floating a => Floating (Tower a) Source # | |

Fractional a => Fractional (Tower a) Source # | |

Data a => Data (Tower a) Source # | |

Defined in Numeric.AD.Internal.Tower gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Tower a -> c (Tower a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Tower a) # toConstr :: Tower a -> Constr # dataTypeOf :: Tower a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Tower a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tower a)) # gmapT :: (forall b. Data b => b -> b) -> Tower a -> Tower a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tower a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tower a -> r # gmapQ :: (forall d. Data d => d -> u) -> Tower a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Tower a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tower a -> m (Tower a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tower a -> m (Tower a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tower a -> m (Tower a) # | |

Num a => Num (Tower a) Source # | |

(Num a, Ord a) => Ord (Tower a) Source # | |

Real a => Real (Tower a) Source # | |

Defined in Numeric.AD.Internal.Tower toRational :: Tower a -> Rational # | |

RealFloat a => RealFloat (Tower a) Source # | |

Defined in Numeric.AD.Internal.Tower floatRadix :: Tower a -> Integer # floatDigits :: Tower a -> Int # floatRange :: Tower a -> (Int, Int) # decodeFloat :: Tower a -> (Integer, Int) # encodeFloat :: Integer -> Int -> Tower a # significand :: Tower a -> Tower a # scaleFloat :: Int -> Tower a -> Tower a # isInfinite :: Tower a -> Bool # isDenormalized :: Tower a -> Bool # isNegativeZero :: Tower a -> Bool # | |

RealFrac a => RealFrac (Tower a) Source # | |

Show a => Show (Tower a) Source # | |

Erf a => Erf (Tower a) Source # | |

InvErf a => InvErf (Tower a) Source # | |

Num a => Mode (Tower a) Source # | |

Defined in Numeric.AD.Internal.Tower | |

Num a => Jacobian (Tower a) Source # | |

Defined in Numeric.AD.Internal.Tower unary :: (Scalar (Tower a) -> Scalar (Tower a)) -> D (Tower a) -> Tower a -> Tower a Source # lift1 :: (Scalar (Tower a) -> Scalar (Tower a)) -> (D (Tower a) -> D (Tower a)) -> Tower a -> Tower a Source # lift1_ :: (Scalar (Tower a) -> Scalar (Tower a)) -> (D (Tower a) -> D (Tower a) -> D (Tower a)) -> Tower a -> Tower a Source # binary :: (Scalar (Tower a) -> Scalar (Tower a) -> Scalar (Tower a)) -> D (Tower a) -> D (Tower a) -> Tower a -> Tower a -> Tower a Source # lift2 :: (Scalar (Tower a) -> Scalar (Tower a) -> Scalar (Tower a)) -> (D (Tower a) -> D (Tower a) -> (D (Tower a), D (Tower a))) -> Tower a -> Tower a -> Tower a Source # lift2_ :: (Scalar (Tower a) -> Scalar (Tower a) -> Scalar (Tower a)) -> (D (Tower a) -> D (Tower a) -> D (Tower a) -> (D (Tower a), D (Tower a))) -> Tower a -> Tower a -> Tower a Source # | |

type Scalar (Tower a) Source # | |

Defined in Numeric.AD.Internal.Tower | |

type D (Tower a) Source # | |

Defined in Numeric.AD.Internal.Tower |

# Taylor Series

taylor :: Fractional a => (Tower a -> Tower a) -> a -> a -> [a] Source #

`taylor f x`

compute the Taylor series of `f`

around `x`

.

taylor0 :: Fractional a => (Tower a -> Tower a) -> a -> a -> [a] Source #

`taylor0 f x`

compute the Taylor series of `f`

around `x`

, zero-padded.

# Maclaurin Series

maclaurin :: Fractional a => (Tower a -> Tower a) -> a -> [a] Source #

`maclaurin f`

compute the Maclaurin series of `f`

maclaurin0 :: Fractional a => (Tower a -> Tower a) -> a -> [a] Source #

`maclaurin f`

compute the Maclaurin series of `f`

, zero-padded

# Derivatives

diff :: Num a => (Tower a -> Tower a) -> a -> a Source #

Compute the first derivative of a function `(a -> a)`

diff' :: Num a => (Tower a -> Tower a) -> a -> (a, a) Source #

Compute the answer and first derivative of a function `(a -> a)`

diffs :: Num a => (Tower a -> Tower a) -> a -> [a] Source #

Compute the answer and all derivatives of a function `(a -> a)`

diffs0 :: Num a => (Tower a -> Tower a) -> a -> [a] Source #

Compute the zero-padded derivatives of a function `(a -> a)`

diffsF :: (Functor f, Num a) => (Tower a -> f (Tower a)) -> a -> f [a] Source #

Compute the answer and all derivatives of a function `(a -> f a)`

diffs0F :: (Functor f, Num a) => (Tower a -> f (Tower a)) -> a -> f [a] Source #

Compute the zero-padded derivatives of a function `(a -> f a)`

# Directional Derivatives

du :: (Functor f, Num a) => (f (Tower a) -> Tower a) -> f (a, a) -> a Source #

Compute a directional derivative of a function `(f a -> a)`

du' :: (Functor f, Num a) => (f (Tower a) -> Tower a) -> f (a, a) -> (a, a) Source #

Compute the answer and a directional derivative of a function `(f a -> a)`

dus :: (Functor f, Num a) => (f (Tower a) -> Tower a) -> f [a] -> [a] Source #

Given a function `(f a -> a)`

, and a tower of derivatives, compute the corresponding directional derivatives.

dus0 :: (Functor f, Num a) => (f (Tower a) -> Tower a) -> f [a] -> [a] Source #

Given a function `(f a -> a)`

, and a tower of derivatives, compute the corresponding directional derivatives, zero-padded

duF :: (Functor f, Functor g, Num a) => (f (Tower a) -> g (Tower a)) -> f (a, a) -> g a Source #

Compute a directional derivative of a function `(f a -> g a)`

duF' :: (Functor f, Functor g, Num a) => (f (Tower a) -> g (Tower a)) -> f (a, a) -> g (a, a) Source #

Compute the answer and a directional derivative of a function `(f a -> g a)`