vector-space-0.19: Vector & affine spaces, linear maps, and derivatives

Copyright | (c) Conal Elliott 2008
License | BSD3
Maintainer | conal@conal.net
Stability | experimental
Safe Haskell | None
Language | Haskell2010

Data.Maclaurin

Contents

- Misc

Description

Infinite derivative towers via linear maps, using the Maclaurin representation. See blog posts http://conal.net/blog/tag/derivative/.

Synopsis

- data a :> b = D b (a :-* (a :> b))
- powVal :: (:>) a b -> b
- derivative :: (:>) a b -> a :-* (a :> b)
- derivAtBasis :: (HasTrie (Basis a), HasBasis a, AdditiveGroup b) => (a :> b) -> Basis a -> a :> b
- type (:~>) a b = a -> a :> b
- pureD :: (AdditiveGroup b, HasBasis a, HasTrie (Basis a)) => b -> a :> b
- fmapD :: HasTrie (Basis a) => (b -> c) -> (a :> b) -> a :> c
- (<$>>) :: HasTrie (Basis a) => (b -> c) -> (a :> b) -> a :> c
- liftD2 :: (HasBasis a, HasTrie (Basis a), AdditiveGroup b, AdditiveGroup c) => (b -> c -> d) -> (a :> b) -> (a :> c) -> a :> d
- liftD3 :: (HasBasis a, HasTrie (Basis a), AdditiveGroup b, AdditiveGroup c, AdditiveGroup d) => (b -> c -> d -> e) -> (a :> b) -> (a :> c) -> (a :> d) -> a :> e
- idD :: (VectorSpace u, HasBasis u, HasTrie (Basis u)) => u :~> u
- fstD :: (HasBasis a, HasTrie (Basis a), HasBasis b, HasTrie (Basis b), Scalar a ~ Scalar b) => (a, b) :~> a
- sndD :: (HasBasis a, HasTrie (Basis a), HasBasis b, HasTrie (Basis b), Scalar a ~ Scalar b) => (a, b) :~> b
- linearD :: (HasBasis u, HasTrie (Basis u), AdditiveGroup v) => (u -> v) -> u :~> v
- distrib :: forall a b c u. (HasBasis a, HasTrie (Basis a), AdditiveGroup u) => (b -> c -> u) -> (a :> b) -> (a :> c) -> a :> u
- (>-<) :: (HasBasis a, HasTrie (Basis a), VectorSpace u) => (u -> u) -> ((a :> u) -> a :> Scalar u) -> (a :> u) -> a :> u
- pairD :: (HasBasis a, HasTrie (Basis a), VectorSpace b, VectorSpace c) => (a :> b, a :> c) -> a :> (b, c)
- unpairD :: HasTrie (Basis a) => (a :> (b, c)) -> (a :> b, a :> c)
- tripleD :: (HasBasis a, HasTrie (Basis a), VectorSpace b, VectorSpace c, VectorSpace d) => (a :> b, a :> c, a :> d) -> a :> (b, c, d)
- untripleD :: HasTrie (Basis a) => (a :> (b, c, d)) -> (a :> b, a :> c, a :> d)

# Documentation

data a :> b Source #

Tower of derivatives.

Constructors

D b (a :-* (a :> b)) infixr 9 |

#### Instances

Instances details

(VectorSpace s, HasBasis s, HasTrie (Basis s), HasNormal (Two s :> Three s)) => HasNormal (Three (Two s :> s)) Source # |
Instance details Defined in Data.Cross Methods normalVec :: Three (Two s :> s) -> Three (Two s :> s) Source #
(VectorSpace s, HasBasis s, HasTrie (Basis s), Basis s ~ ()) => HasNormal (Two (One s :> s)) Source # |
Instance details Defined in Data.Cross Methods normalVec :: Two (One s :> s) -> Two (One s :> s) Source #
(AdditiveGroup v, HasBasis u, HasTrie (Basis u), IfB v) => IfB (u :> v) Source # |
Instance details Defined in Data.Maclaurin Methods ifB :: bool ~ BooleanOf (u :> v) => bool -> (u :> v) -> (u :> v) -> u :> v Source #
OrdB v => OrdB (u :> v) Source # |
Instance details Defined in Data.Maclaurin Methods (<*) :: bool ~ BooleanOf (u :> v) => (u :> v) -> (u :> v) -> bool Source # (<=*) :: bool ~ BooleanOf (u :> v) => (u :> v) -> (u :> v) -> bool Source # (>*) :: bool ~ BooleanOf (u :> v) => (u :> v) -> (u :> v) -> bool Source # (>=*) :: bool ~ BooleanOf (u :> v) => (u :> v) -> (u :> v) -> bool Source #
(HasBasis a, s ~ Scalar a, HasTrie (Basis a), Floating s, VectorSpace s, Scalar s ~ s) => Floating (a :> s) Source # |

Instance details

Defined in Data.Maclaurin

Methods

pi :: a :> s Source #

exp :: (a :> s) -> a :> s Source #

log :: (a :> s) -> a :> s Source #

sqrt :: (a :> s) -> a :> s Source #

(**) :: (a :> s) -> (a :> s) -> a :> s Source #

logBase :: (a :> s) -> (a :> s) -> a :> s Source #

sin :: (a :> s) -> a :> s Source #

cos :: (a :> s) -> a :> s Source #

tan :: (a :> s) -> a :> s Source #

asin :: (a :> s) -> a :> s Source #

acos :: (a :> s) -> a :> s Source #

atan :: (a :> s) -> a :> s Source #

sinh :: (a :> s) -> a :> s Source #

cosh :: (a :> s) -> a :> s Source #

tanh :: (a :> s) -> a :> s Source #

asinh :: (a :> s) -> a :> s Source #

acosh :: (a :> s) -> a :> s Source #

atanh :: (a :> s) -> a :> s Source #

log1p :: (a :> s) -> a :> s Source #

expm1 :: (a :> s) -> a :> s Source #

log1pexp :: (a :> s) -> a :> s Source #

log1mexp :: (a :> s) -> a :> s Source #

(HasBasis a, s ~ Scalar a, HasTrie (Basis a), Num s, VectorSpace s, Scalar s ~ s) => Num (a :> s) Source # |
Instance details Defined in Data.Maclaurin Methods (+) :: (a :> s) -> (a :> s) -> a :> s Source # (-) :: (a :> s) -> (a :> s) -> a :> s Source # (*) :: (a :> s) -> (a :> s) -> a :> s Source # negate :: (a :> s) -> a :> s Source # abs :: (a :> s) -> a :> s Source # signum :: (a :> s) -> a :> s Source # fromInteger :: Integer -> a :> s Source #
(HasBasis a, s ~ Scalar a, HasTrie (Basis a), Fractional s, VectorSpace s, Scalar s ~ s) => Fractional (a :> s) Source # |
Instance details Defined in Data.Maclaurin Methods (/) :: (a :> s) -> (a :> s) -> a :> s Source # recip :: (a :> s) -> a :> s Source # fromRational :: Rational -> a :> s Source #
Show b => Show (a :> b) Source # |
Instance details Defined in Data.Maclaurin Methods showsPrec :: Int -> (a :> b) -> ShowS Source # show :: (a :> b) -> String Source # showList :: [a :> b] -> ShowS Source #
Eq (a :> b) Source # |
Instance details Defined in Data.Maclaurin Methods (==) :: (a :> b) -> (a :> b) -> Bool Source # (/=) :: (a :> b) -> (a :> b) -> Bool Source #
(AdditiveGroup b, HasBasis a, HasTrie (Basis a), OrdB b, IfB b, Ord b) => Ord (a :> b) Source # |
Instance details Defined in Data.Maclaurin Methods compare :: (a :> b) -> (a :> b) -> Ordering Source # (<) :: (a :> b) -> (a :> b) -> Bool Source # (<=) :: (a :> b) -> (a :> b) -> Bool Source # (>) :: (a :> b) -> (a :> b) -> Bool Source # (>=) :: (a :> b) -> (a :> b) -> Bool Source # max :: (a :> b) -> (a :> b) -> a :> b Source # min :: (a :> b) -> (a :> b) -> a :> b Source #
(HasBasis a, HasTrie (Basis a), AdditiveGroup u) => AdditiveGroup (a :> u) Source # |
Instance details Defined in Data.Maclaurin Methods zeroV :: a :> u Source # (^+^) :: (a :> u) -> (a :> u) -> a :> u Source # negateV :: (a :> u) -> a :> u Source # (^-^) :: (a :> u) -> (a :> u) -> a :> u Source #
(HasTrie (Basis a), HasCross2 v) => HasCross2 (a :> v) Source # |
Instance details Defined in Data.Cross Methods cross2 :: (a :> v) -> a :> v Source #
(HasBasis a, HasTrie (Basis a), VectorSpace v, HasCross3 v) => HasCross3 (a :> v) Source # |
Instance details Defined in Data.Cross Methods cross3 :: (a :> v) -> (a :> v) -> a :> v Source #
(HasBasis s, HasTrie (Basis s), Basis s ~ ()) => HasNormal (One s :> Two s) Source # |
Instance details Defined in Data.Cross Methods normalVec :: (One s :> Two s) -> One s :> Two s Source #
(Num s, HasTrie (Basis (s, s)), HasBasis s, Basis s ~ ()) => HasNormal (Two s :> Three s) Source # |
Instance details Defined in Data.Cross Methods normalVec :: (Two s :> Three s) -> Two s :> Three s Source #
(InnerSpace u, s ~ Scalar u, AdditiveGroup s, HasBasis a, HasTrie (Basis a)) => InnerSpace (a :> u) Source # |
Instance details Defined in Data.Maclaurin Methods (<.>) :: (a :> u) -> (a :> u) -> Scalar (a :> u) Source #
(HasBasis a, HasTrie (Basis a), VectorSpace u) => VectorSpace (a :> u) Source # |

Instance details

Defined in Data.Maclaurin

Associated Types

type Scalar (a :> u) |
Instance details Defined in Data.Maclaurin type Scalar (a :> u) = a :> Scalar u

Methods

(*^) :: Scalar (a :> u) -> (a :> u) -> a :> u Source #

type BooleanOf (a :> b) Source # |
Instance details Defined in Data.Maclaurin type BooleanOf (a :> b) = BooleanOf b
type Scalar (a :> u) Source # |
Instance details Defined in Data.Maclaurin type Scalar (a :> u) = a :> Scalar u

powVal :: (:>) a b -> b Source #

derivative :: (:>) a b -> a :-* (a :> b) Source #

derivAtBasis :: (HasTrie (Basis a), HasBasis a, AdditiveGroup b) => (a :> b) -> Basis a -> a :> b Source #

Sample the derivative at a basis element. Optimized for partial application to save work for non-scalar derivatives.

type (:~>) a b = a -> a :> b Source #

Infinitely differentiable functions

pureD :: (AdditiveGroup b, HasBasis a, HasTrie (Basis a)) => b -> a :> b Source #

Constant derivative tower.

fmapD :: HasTrie (Basis a) => (b -> c) -> (a :> b) -> a :> c Source #

Map a linear function over a derivative tower.

(<$>>) :: HasTrie (Basis a) => (b -> c) -> (a :> b) -> a :> c infixl 4 Source #

Map a linear function over a derivative tower.

liftD2 :: (HasBasis a, HasTrie (Basis a), AdditiveGroup b, AdditiveGroup c) => (b -> c -> d) -> (a :> b) -> (a :> c) -> a :> d Source #

Apply a linear binary function over derivative towers.

liftD3 :: (HasBasis a, HasTrie (Basis a), AdditiveGroup b, AdditiveGroup c, AdditiveGroup d) => (b -> c -> d -> e) -> (a :> b) -> (a :> c) -> (a :> d) -> a :> e Source #

Apply a linear ternary function over derivative towers.

idD :: (VectorSpace u, HasBasis u, HasTrie (Basis u)) => u :~> u Source #

Differentiable identity function. Sometimes called "the derivation variable" or similar, but it's not really a variable.

fstD :: (HasBasis a, HasTrie (Basis a), HasBasis b, HasTrie (Basis b), Scalar a ~ Scalar b) => (a, b) :~> a Source #

Differentiable version of `fst`

sndD :: (HasBasis a, HasTrie (Basis a), HasBasis b, HasTrie (Basis b), Scalar a ~ Scalar b) => (a, b) :~> b Source #

Differentiable version of `snd`

linearD :: (HasBasis u, HasTrie (Basis u), AdditiveGroup v) => (u -> v) -> u :~> v Source #

Every linear function has a constant derivative equal to the function itself (as a linear map).

distrib :: forall a b c u. (HasBasis a, HasTrie (Basis a), AdditiveGroup u) => (b -> c -> u) -> (a :> b) -> (a :> c) -> a :> u Source #

Derivative tower for applying a binary function that distributes over addition, such as multiplication. A bit weaker assumption than bilinearity. Is bilinearity necessary for correctness here?

(>-<) :: (HasBasis a, HasTrie (Basis a), VectorSpace u) => (u -> u) -> ((a :> u) -> a :> Scalar u) -> (a :> u) -> a :> u infix 0 Source #

Specialized chain rule. See also `(\@.)`

# Misc

pairD :: (HasBasis a, HasTrie (Basis a), VectorSpace b, VectorSpace c) => (a :> b, a :> c) -> a :> (b, c) Source #

unpairD :: HasTrie (Basis a) => (a :> (b, c)) -> (a :> b, a :> c) Source #

tripleD :: (HasBasis a, HasTrie (Basis a), VectorSpace b, VectorSpace c, VectorSpace d) => (a :> b, a :> c, a :> d) -> a :> (b, c, d) Source #

untripleD :: HasTrie (Basis a) => (a :> (b, c, d)) -> (a :> b, a :> c, a :> d) Source #