Copyright | (c) Conal Elliott 2008 |
---|---|
License | BSD3 |
Maintainer | conal@conal.net |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
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
Tower of derivatives.
Instances
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.
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 #
tripleD :: ( HasBasis a, HasTrie ( Basis a), VectorSpace b, VectorSpace c, VectorSpace d) => (a :> b, a :> c, a :> d) -> a :> (b, c, d) Source #