circuits-diff
Safe HaskellNone
LanguageGHC2024

Circuit.Diff.Inverse

Description

Inverse and implicit functions via Newton iteration on Diff.

These are first-order theorems in action: the inverse-function theorem says (f⁻¹)'(f(a)) = 1/f'(a), and the implicit-function theorem says dydx = -(∂F∂y)⁻¹ · ∂F/∂x. We use those derivatives (pulled back by Diff) to drive Newton steps, and verify against exact oracles.

Synopsis

Newton iteration

newton :: forall {k} a (p :: k). (Subtractive a, Divisive a) => Diff p a a -> a -> a -> Int -> a Source #

Newton iteration for solving f(x) = target.

newton f target x0 n takes n steps starting from x0.

inverseN :: forall {k} a (p :: k). (Subtractive a, Divisive a) => Diff p a a -> a -> a -> Int -> a Source #

Newton iteration for the inverse value: find x such that f(x) = y.

implicit1N :: forall {k} b (p :: k). (Subtractive b, Divisive b) => Diff p b b -> b -> Int -> b Source #

Newton iteration for a scalar implicit equation: find y such that g(y) = 0. The caller fixes any ambient parameters (e.g. x in F(x,y)=0) by building them into g with 'constDiff.

Primitives

varDiff :: forall {k} (p :: k) a. Diff p a a Source #

The identity differentiable function x ↦ x.

constDiff :: forall {k} a b (p :: k). Additive a => b -> Diff p a b Source #

Constant differentiable function.