02.20: the general builder's arithmetic. A fixed expression language over named variables with rational constants (sum, product, positive part, absolute value, reciprocal), read in the reals and computed in the rationals; box arithmetic giving an expression's range and Lipschitz constant over a box of its variables; polynomials with rational coefficients in Horner form, their derivatives and bounds; and rational upper bounds for the exponential on [0,1] and for Grönwall's bound. Every computation here reduces in the kernel. Pure arithmetic, no mind.
02.20: an expression over variables V with rational constants: sums, products, the positive part, the absolute value and the reciprocal.
- const {V : Type u} : ℚ → RExpr V
- var {V : Type u} : V → RExpr V
- add {V : Type u} : RExpr V → RExpr V → RExpr V
- mul {V : Type u} : RExpr V → RExpr V → RExpr V
- pos {V : Type u} : RExpr V → RExpr V
- abs {V : Type u} : RExpr V → RExpr V
- inv {V : Type u} : RExpr V → RExpr V
Instances For
02.20: an expression read in the reals, at real values of its variables.
Equations
- MindFormal.RExpr.eval ρ (MindFormal.RExpr.const c) = ↑c
- MindFormal.RExpr.eval ρ (MindFormal.RExpr.var v) = ρ v
- MindFormal.RExpr.eval ρ (a.add b) = MindFormal.RExpr.eval ρ a + MindFormal.RExpr.eval ρ b
- MindFormal.RExpr.eval ρ (a.mul b) = MindFormal.RExpr.eval ρ a * MindFormal.RExpr.eval ρ b
- MindFormal.RExpr.eval ρ a.pos = max (MindFormal.RExpr.eval ρ a) 0
- MindFormal.RExpr.eval ρ a.abs = |MindFormal.RExpr.eval ρ a|
- MindFormal.RExpr.eval ρ a.inv = (MindFormal.RExpr.eval ρ a)⁻¹
Instances For
02.20: an expression computed exactly in the rationals, at rational values of its variables.
Equations
- MindFormal.RExpr.evalQ ρ (MindFormal.RExpr.const c) = c
- MindFormal.RExpr.evalQ ρ (MindFormal.RExpr.var v) = ρ v
- MindFormal.RExpr.evalQ ρ (a.add b) = MindFormal.RExpr.evalQ ρ a + MindFormal.RExpr.evalQ ρ b
- MindFormal.RExpr.evalQ ρ (a.mul b) = MindFormal.RExpr.evalQ ρ a * MindFormal.RExpr.evalQ ρ b
- MindFormal.RExpr.evalQ ρ a.pos = max (MindFormal.RExpr.evalQ ρ a) 0
- MindFormal.RExpr.evalQ ρ a.abs = |MindFormal.RExpr.evalQ ρ a|
- MindFormal.RExpr.evalQ ρ a.inv = (MindFormal.RExpr.evalQ ρ a)⁻¹
Instances For
02.20: a rational multiple.
Equations
- MindFormal.RExpr.smul c a = (MindFormal.RExpr.const c).mul a
Instances For
02.20: a finite sum over a list of indices.
Equations
- MindFormal.RExpr.sumL L f = List.foldr (fun (x : α) (acc : MindFormal.RExpr V) => (f x).add acc) (MindFormal.RExpr.const 0) L
Instances For
02.20: the product rule: the range from the four corner products, the Lipschitz constant |a|·L_b + |b|·L_a.
Equations
- One or more equations did not get rendered due to their size.
Instances For
02.20: box arithmetic. Each variable ranges over its box [lo,hi] with Lipschitz constant one.
Equations
- MindFormal.RExpr.bound B (MindFormal.RExpr.const c) = { ok := true, lo := c, hi := c, lip := 0 }
- MindFormal.RExpr.bound B (MindFormal.RExpr.var v) = { ok := true, lo := (B v).1, hi := (B v).2, lip := 1 }
- MindFormal.RExpr.bound B (a.add b) = (MindFormal.RExpr.bound B a).add (MindFormal.RExpr.bound B b)
- MindFormal.RExpr.bound B (a.mul b) = (MindFormal.RExpr.bound B a).mul (MindFormal.RExpr.bound B b)
- MindFormal.RExpr.bound B a.pos = (MindFormal.RExpr.bound B a).pos
- MindFormal.RExpr.bound B a.abs = (MindFormal.RExpr.bound B a).abs
- MindFormal.RExpr.bound B a.inv = (MindFormal.RExpr.bound B a).inv
Instances For
02.20: box arithmetic is sound. If the enclosure is defined, every point of the box reads into its range, and two points of the box whose variables differ by at most δ read at most lip·δ apart.
Polynomials with rational coefficients, c₀ + x(c₁ + x(c₂ + …)).
02.20: a polynomial computed exactly in the rationals.
Equations
- MindFormal.qeval cs x = List.foldr (fun (c acc : ℚ) => c + x * acc) 0 cs
Instances For
02.20: a polynomial read in the reals.
Equations
- MindFormal.reval [] x✝ = 0
- MindFormal.reval (c :: cs) x✝ = ↑c + x✝ * MindFormal.reval cs x✝
Instances For
02.20: coefficientwise sum.
Equations
- MindFormal.padd [] x✝ = x✝
- MindFormal.padd x✝ [] = x✝
- MindFormal.padd (x_2 :: xs) (y :: ys) = (x_2 + y) :: MindFormal.padd xs ys
Instances For
02.20: the derivative's coefficients: (c + x·p)' = p + x·p'.
Equations
- MindFormal.pderiv [] = []
- MindFormal.pderiv (head :: cs) = MindFormal.padd cs (0 :: MindFormal.pderiv cs)
Instances For
02.20: the coefficients' absolute values read at h, a bound for |x| ≤ h.
Equations
- MindFormal.pabs cs h = List.foldr (fun (c acc : ℚ) => |c| + h * acc) 0 cs
Instances For
02.20: the polynomial has the derivative pderiv computes.
The exponential and Grönwall's bound, from above in the rationals.
02.20: a rational upper bound for exp y on [0,1]: eight Taylor terms and Mathlib's remainder.
Equations
- MindFormal.expUpper y = ∑ i ∈ Finset.range 8, y ^ i / ↑i.factorial + y ^ 8 * 9 / (↑(Nat.factorial 8) * 8)