| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Circuit.Diff.Taylor
Description
Scalar Taylor tower as a circuits arrow.
A value Taylor n a b is a morphism from a to b whose values are
truncated Taylor series of order n. The internal representation is
structural: scalar wires carry n+1 coefficients, unit wires carry (),
and product wires pair the two shapes. This makes the cartesian instances
straightforward by recursion on the value shape.
The carrier is intentionally scalar-first: objects are built from Double
and (,), and the bimonoid instances are supplied for Double (and the
unit). The Traced instance ties a lazy knot on the value shape, just as
the pure (->) trace does; for stable feedback the coefficients resolve
order-by-order.
Scalar primitives (addT, mulT, etc.) are implemented via
Jet, so they inherit the correct truncated-series recurrences
for addition, multiplication, and elementary functions.
Synopsis
- newtype Taylor (n :: Nat) a b = Taylor {}
- data TaylorV (n :: Nat) a where
- constT :: forall (n :: Nat). Double -> Taylor n Double Double
- addT :: forall (n :: Nat). Taylor n (Double, Double) Double
- mulT :: forall (n :: Nat). Taylor n (Double, Double) Double
- sinT :: forall (n :: Nat). Taylor n Double Double
- cosT :: forall (n :: Nat). Taylor n Double Double
- expT :: forall (n :: Nat). Taylor n Double Double
- logT :: forall (n :: Nat). Taylor n Double Double
- polyT :: forall (n :: Nat). [Double] -> Taylor n Double Double
- shiftT :: forall (n :: Nat). Double -> Taylor n Double Double
- evalTaylor :: forall (n :: Nat). KnownNat n => Taylor n Double Double -> Double -> [Double]
- evalTaylorDerivs :: forall (n :: Nat). KnownNat n => Taylor n Double Double -> Double -> [Double]
- taylorCoeffsFromDiff :: forall {k} (p :: k). Diff p Double Double -> Double -> Int -> [Double]
- approxTaylorFromDiff :: forall {k} (n :: Nat) (p :: k). KnownNat n => Diff p Double Double -> Double -> Taylor n Double Double
Taylor arrow
newtype Taylor (n :: Nat) a b Source #
Truncated Taylor series arrow of order n.
Instances
Scalar primitives
Polynomial construction and evaluation
polyT :: forall (n :: Nat). [Double] -> Taylor n Double Double Source #
Build a polynomial morphism from coefficients [c0, c1, ..., ck],
mapping the input series u to c0 + c1*u + c2*u^2 + ... + ck*u^k.
shiftT :: forall (n :: Nat). Double -> Taylor n Double Double Source #
Shift the input series by a constant x0.
evalTaylor :: forall (n :: Nat). KnownNat n => Taylor n Double Double -> Double -> [Double] Source #
Evaluate a scalar Taylor morphism at a point and return the Taylor
coefficients [f(x), f'(x), f''(x)/2!, ...].
evalTaylorDerivs :: forall (n :: Nat). KnownNat n => Taylor n Double Double -> Double -> [Double] Source #
Evaluate a scalar Taylor morphism and return the raw derivatives
[f(x), f'(x), f''(x), ..., f^(n)(x)].