| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Circuit.Diff.Jet
Description
Jets via truncated Taylor series.
A Jet is a finite tower of Taylor coefficients
c0 + c1*h + c2*h^2 + ... + cn*h^n
around a primal point. Elementary functions act coefficient-wise via the
usual dual-number recurrences, so a NumHask-polymorphic function
f :: (ExpField a, TrigField a) => a -> a applied to
returns the first variable n an+1 Taylor coefficients of f at a.
This is the "iterated" direction of Diff: where Diff carries one
pullback, a jet carries the whole truncated tower. The two interoperate
through 'jetFromDiff, which seeds the tower from a first-order pullback.
Synopsis
- newtype Jet a = Jet {
- coefficients :: [a]
- jetOrder :: Jet a -> Int
- variable :: (Additive a, Multiplicative a) => Int -> a -> Jet a
- constant :: Additive a => Int -> a -> Jet a
- fromDiff :: forall {k} a (p :: k). Multiplicative a => Diff p a a -> a -> Jet a
- taylorDers :: (Additive a, Multiplicative a, FromInteger a) => Jet a -> [a]
- taylor :: (ExpField a, FromInteger a) => (Jet a -> Jet a) -> Int -> a -> [a]
- differentiate :: (Multiplicative a, FromInteger a) => Jet a -> Jet a
- integrate :: (Divisive a, FromInteger a) => a -> Jet a -> Jet a
- scale :: Multiplicative a => a -> Jet a -> Jet a
- resize :: Additive a => Int -> Jet a -> Jet a
Jet type
Truncated Taylor series stored as coefficients [c0, c1, ..., cn]
representing c0 + c1*h + c2*h^2 + ... + cn*h^n.
Constructors
| Jet | |
Fields
| |
Instances
| Eq a => Eq (Jet a) Source # | |
| Show a => Show (Jet a) Source # | |
| Additive a => Additive (Jet a) Source # | |
| Subtractive a => Subtractive (Jet a) Source # | |
| (Subtractive a, Divisive a, ExpField a, FromInteger a) => ExpField (Jet a) Source # | |
| (Subtractive a, Divisive a, ExpField a, TrigField a, FromInteger a) => TrigField (Jet a) Source # | |
| (Additive a, Subtractive a, Multiplicative a, Divisive a) => Divisive (Jet a) Source # | |
| (Additive a, Multiplicative a) => Multiplicative (Jet a) Source # | |
| FromInteger a => FromInteger (Jet a) Source # | |
Defined in Circuit.Diff.Jet Methods fromInteger :: Integer -> Jet a # | |
Construction
variable :: (Additive a, Multiplicative a) => Int -> a -> Jet a Source #
Build a jet of order n representing the input variable a + h.
Coefficient views
taylorDers :: (Additive a, Multiplicative a, FromInteger a) => Jet a -> [a] Source #
Convert Taylor coefficients to raw derivatives.
taylorDers (Jet [c0, c1, c2]) = [c0, 1!*c1, 2!*c2]
taylor :: (ExpField a, FromInteger a) => (Jet a -> Jet a) -> Int -> a -> [a] Source #
Apply a jet-level function at a point and return the raw
derivatives [f(a), f'(a), f''(a), ..., f^(n)(a)].
Series operations
differentiate :: (Multiplicative a, FromInteger a) => Jet a -> Jet a Source #
Term-by-term differentiation of a Taylor series.
differentiate (Jet [c0, c1, c2, c3]) = Jet [c1, 2*c2, 3*c3]