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

Stabilityexperimental
Maintainerconal@conal.net
Safe HaskellNone

Data.Maclaurin

Contents

Description

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

Synopsis

Documentation

data a :> b Source

Tower of derivatives.

Constructors

D 

Fields

powVal :: b
 
derivative :: a :-* (a :> b)
 

Instances

(Num s, VectorSpace s, HasBasis s, HasTrie (Basis s), HasNormal (:> (Two s) (Three s))) => HasNormal (Three (:> (Two s) s)) 
(Num s, VectorSpace s, HasBasis s, HasTrie (Basis s), ~ * (Basis s) ()) => HasNormal (Two (:> (One s) s)) 
Eq b => Eq (:> a b) 
(Fractional (:> a s), HasBasis a, ~ * s (Scalar a), HasTrie (Basis a), Floating s, VectorSpace s, ~ * (Scalar s) s) => Floating (:> a s) 
(Num (:> a s), HasBasis a, ~ * s (Scalar a), HasTrie (Basis a), Fractional s, VectorSpace s, ~ * (Scalar s) s) => Fractional (:> a s) 
(HasBasis a, ~ * s (Scalar a), HasTrie (Basis a), Num s, VectorSpace s, ~ * (Scalar s) s) => Num (:> a s) 
(Eq (:> a b), AdditiveGroup b, HasBasis a, HasTrie (Basis a), OrdB b, IfB b, Ord b) => Ord (:> a b) 
Show b => Show (:> a b) 
(Boolean (BooleanOf (:> u v)), AdditiveGroup v, HasBasis u, HasTrie (Basis u), IfB v) => IfB (:> u v) 
(Boolean (BooleanOf (:> u v)), AdditiveGroup v, HasBasis u, HasTrie (Basis u), OrdB v) => OrdB (:> u v) 
(HasBasis a, HasTrie (Basis a), AdditiveGroup u) => AdditiveGroup (:> a u) 
(VectorSpace (:> a u), AdditiveGroup (Scalar (:> a u)), InnerSpace u, ~ * s (Scalar u), AdditiveGroup s, HasBasis a, HasTrie (Basis a)) => InnerSpace (:> a u) 
(AdditiveGroup (:> a u), HasBasis a, HasTrie (Basis a), VectorSpace u, AdditiveGroup (Scalar u)) => VectorSpace (:> a u) 
(HasBasis a, HasTrie (Basis a), VectorSpace v, HasCross3 v) => HasCross3 (:> a v) 
(HasBasis a, HasTrie (Basis a), VectorSpace v, HasCross2 v) => HasCross2 (:> a v) 
(Num s, HasTrie (Basis (s, s)), HasBasis s, ~ * (Basis s) ()) => HasNormal (:> (Two s) (Three s)) 
(HasBasis s, HasTrie (Basis s), ~ * (Basis s) ()) => HasNormal (:> (One s) (Two s)) 

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

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

type :~> a b = a -> a :> bSource

Infinitely differentiable functions

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

Constant derivative tower.

fmapD :: (HasBasis a, HasTrie (Basis a), AdditiveGroup b) => (b -> c) -> (a :> b) -> a :> cSource

Map a linear function over a derivative tower.

(<$>>) :: (HasBasis a, HasTrie (Basis a), AdditiveGroup b) => (b -> c) -> (a :> b) -> a :> cSource

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 :> dSource

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 :> eSource

Apply a linear ternary function over derivative towers.

idD :: (VectorSpace u, s ~ Scalar u, VectorSpace (u :> u), VectorSpace s, HasBasis u, HasTrie (Basis u)) => u :~> uSource

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) :~> aSource

Differentiable version of fst

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

Differentiable version of snd

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

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 b, AdditiveGroup c, AdditiveGroup u) => (b -> c -> u) -> (a :> b) -> (a :> c) -> a :> uSource

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, AdditiveGroup (Scalar u)) => (u -> u) -> ((a :> u) -> a :> Scalar u) -> (a :> u) -> a :> uSource

Specialized chain rule. See also '(@.)'

Misc

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

unpairD :: (HasBasis a, HasTrie (Basis a), VectorSpace a, VectorSpace b, VectorSpace c, Scalar b ~ Scalar c) => (a :> (b, c)) -> (a :> b, a :> c)Source

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

untripleD :: (HasBasis a, HasTrie (Basis a), VectorSpace a, VectorSpace b, VectorSpace c, VectorSpace d, Scalar b ~ Scalar c, Scalar c ~ Scalar d) => (a :> (b, c, d)) -> (a :> b, a :> c, a :> d)Source