FmaErrApprox

# Library FmaErrApprox

`Require Export AllFloat.
Require Export Veltkamp.
Require Export FmaErr.
Section tBounded.
Variable bo : Fbound.
Variable radix : Z.
Variable p : nat.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Hypothesis radixMoreThanOne : (1 < radix)%Z.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ radixMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Hypothesis pGivesBound : Zpos (vNum bo) = Zpower_nat radix p.
Hypothesis precisionGreaterThanOne : 3 <= p.
Variables a x b ph pl uh z:float.
Hypothesis Fb: Fbounded bo b.
Hypothesis Fa: Fbounded bo a.
Hypothesis Fx: Fbounded bo x.
Hypothesis Cb: Fcanonic radix bo b.
Hypothesis Nph: Fnormal radix bo ph.
Hypothesis Nz: Fnormal radix bo z.
Hypothesis Nuh: Fnormal radix bo uh.
Hypothesis Exp1: (- dExp bo <= Fexp a+Fexp x)%Z.
Hypothesis zDef : Closest bo radix (a*x+b)%R z.
Hypothesis phDef: Closest bo radix (a*x)%R ph.
Hypothesis plDef: (FtoRradix pl=a*x-ph)%R.
Hypothesis uhDef: Closest bo radix (ph+b)%R uh.
Hypothesis Posit: (0 <= a*x+b)%R.
Lemma zPos: (0 <= z)%R.
Lemma uhPos: (0 <= uh)%R.
Theorem tBounded_aux: exists v:float, Fbounded bo v /\ (FtoRradix v=uh-z)%R.
End tBounded.
Section tBounded2.
Variable bo : Fbound.
Variable radix : Z.
Variable p : nat.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Hypothesis radixMoreThanOne : (1 < radix)%Z.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ radixMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Hypothesis pGivesBound : Zpos (vNum bo) = Zpower_nat radix p.
Hypothesis precisionGreaterThanOne : 3 <= p.
Variables a x b ph pl uh z:float.
Hypothesis Fb: Fbounded bo b.
Hypothesis Fa: Fbounded bo a.
Hypothesis Fx: Fbounded bo x.
Hypothesis Cb: Fcanonic radix bo b.
Hypothesis Nph: Fnormal radix bo ph \/ (FtoRradix ph=0).
Hypothesis Nz: Fnormal radix bo z \/ (FtoRradix z =0).
Hypothesis Nuh: Fnormal radix bo uh \/ (FtoRradix uh=0).
Hypothesis Exp1: (- dExp bo <= Fexp a+Fexp x)%Z.
Hypothesis zDef : Closest bo radix (a*x+b)%R z.
Hypothesis phDef: Closest bo radix (a*x)%R ph.
Hypothesis plDef: (FtoRradix pl=a*x-ph)%R.
Hypothesis uhDef: Closest bo radix (ph+b)%R uh.
Theorem tBounded: exists v:float, Fbounded bo v /\ (FtoRradix v=uh-z)%R.
End tBounded2.
Section uhExact.
Variable bo : Fbound.
Variable radix : Z.
Variable p : nat.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Hypothesis radixMoreThanOne : (1 < radix)%Z.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ radixMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Hypothesis pGivesBound : Zpos (vNum bo) = Zpower_nat radix p.
Hypothesis precisionGreaterThanOne : 3 <= p.
Variables a x b ph pl uh ul z t v w:float.
Hypothesis Fb: Fbounded bo b.
Hypothesis Fa: Fbounded bo a.
Hypothesis Fx: Fbounded bo x.
Hypothesis Cb: Fcanonic radix bo b.
Hypothesis Nph: Fnormal radix bo ph \/ (FtoRradix ph=0).
Hypothesis Nuh: Fnormal radix bo uh \/ (FtoRradix uh=0).
Hypothesis Nz: Fnormal radix bo z \/ (FtoRradix z=0).
Hypothesis Nw: Fnormal radix bo w \/ (FtoRradix w=0).
Hypothesis Fpl: Fbounded bo pl.
Hypothesis Exp1: (- dExp bo <= Fexp a+Fexp x)%Z.
Hypothesis zDef : Closest bo radix (a*x+b)%R z.
Hypothesis phDef: Closest bo radix (a*x)%R ph.
Hypothesis plDef: (FtoRradix pl=a*x-ph)%R.
Hypothesis uhDef: Closest bo radix (ph+b)%R uh.
Hypothesis ulDef: (FtoRradix ul=ph+b-uh)%R.
Hypothesis tDef : Closest bo radix (uh-z)%R t.
Hypothesis vDef : Closest bo radix (pl+ul)%R v.
Hypothesis wDef : Closest bo radix (t+v)%R w.
Hypothesis Case1:(FtoRradix ul=0)%R.
Theorem ErrFmaApprox_1_aux:
Fnormal radix bo z -> Fnormal radix bo w ->
(Rabs (z+w-(a*x+b)) <= (3*radix/2+/2)*powerRZ radix (2-2*p)*Rabs z)%R.
Theorem ErrFmaApprox_1: (Rabs (z+w-(a*x+b)) <= (3*radix/2+/2)*powerRZ radix (2-2*p)*Rabs z)%R.
End uhExact.
Section uhInexact.
Variable bo : Fbound.
Variable radix : Z.
Variable p : nat.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Hypothesis radixMoreThanOne : (1 < radix)%Z.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ radixMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Hypothesis pGivesBound : Zpos (vNum bo) = Zpower_nat radix p.
Hypothesis precisionGreaterThanOne : 4 <= p.
Lemma RleRoundedAbs: forall (f:float) (r:R), (Closest bo radix r f) ->
(Fnormal radix bo f) -> (-(dExp bo) < Fexp f)%Z ->
((powerRZ radix (p - 1) + - / (2 * radix)) * powerRZ radix (Fexp f) <= Rabs r)%R.
Variables a x b ph pl uh ul z t v w:float.
Hypothesis Fb: Fbounded bo b.
Hypothesis Fa: Fbounded bo a.
Hypothesis Fx: Fbounded bo x.
Hypothesis Cb: Fcanonic radix bo b.
Hypothesis Nph: Fnormal radix bo ph.
Hypothesis Nuh: Fnormal radix bo uh.
Hypothesis Nz: Fnormal radix bo z.
Hypothesis Nw: Fnormal radix bo w.
Hypothesis Nv: Fnormal radix bo v.
Hypothesis Exp1: (- dExp bo <= Fexp a+Fexp x)%Z.
Hypothesis zDef : Closest bo radix (a*x+b)%R z.
Hypothesis phDef: Closest bo radix (a*x)%R ph.
Hypothesis plDef: (FtoRradix pl=a*x-ph)%R.
Hypothesis uhDef: Closest bo radix (ph+b)%R uh.
Hypothesis ulDef: (FtoRradix ul=ph+b-uh)%R.
Hypothesis tDef : Closest bo radix (uh-z)%R t.
Hypothesis vDef : Closest bo radix (pl+ul)%R v.
Hypothesis wDef : Closest bo radix (t+v)%R w.
Hypothesis Case2: ~(FtoRradix ul=0)%R.
Lemma LeExp1: (Fexp ph <= Fexp uh+1)%Z.
Lemma LeExp2: (Fexp uh <= Fexp z+1)%Z.
Lemma LeExp3: (Fexp ph = Fexp uh+1)%Z -> (Fexp uh = Fexp z+1)%Z -> False.
Lemma LeExp: (powerRZ radix (Fexp ph)+powerRZ radix (Fexp uh) <= 2*powerRZ radix (Fexp z+1))%R.
Lemma vLe_aux: (Rabs (pl+ul) <= powerRZ radix (Fexp z)*radix)%R.
Lemma vLe: (Rabs v <= powerRZ radix (Fexp z)*radix)%R.
Lemma tLe: (Rabs t <= powerRZ radix (Fexp z)*(radix+1))%R.
Lemma wLe: (Rabs w <= powerRZ radix (Fexp z)*(2*radix+1))%R.
Theorem ErrFmaApprox_2_aux:(Rabs (z+w-(a*x+b)) <= (3*radix/2+/2)*powerRZ radix (2-2*p)*Rabs z)%R.
End uhInexact.
Section uhInexact2.
Variable bo : Fbound.
Variable radix : Z.
Variable p : nat.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Hypothesis radixMoreThanOne : (1 < radix)%Z.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ radixMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Hypothesis pGivesBound : Zpos (vNum bo) = Zpower_nat radix p.
Hypothesis precisionGreaterThanOne : 4 <= p.
Variables a x b ph pl uh ul z t v w:float.
Hypothesis Fb: Fbounded bo b.
Hypothesis Fa: Fbounded bo a.
Hypothesis Fx: Fbounded bo x.
Hypothesis Cb: Fcanonic radix bo b.
Hypothesis Nph: Fnormal radix bo ph \/ (FtoRradix ph=0).
Hypothesis Nuh: Fnormal radix bo uh \/ (FtoRradix uh=0).
Hypothesis Nz: Fnormal radix bo z \/ (FtoRradix z =0).
Hypothesis Nw: Fnormal radix bo w \/ (FtoRradix w =0).
Hypothesis Nv: Fnormal radix bo v \/ (FtoRradix v =0).
Hypothesis Exp1: (- dExp bo <= Fexp a+Fexp x)%Z.
Hypothesis zDef : Closest bo radix (a*x+b)%R z.
Hypothesis phDef: Closest bo radix (a*x)%R ph.
Hypothesis plDef: (FtoRradix pl=a*x-ph)%R.
Hypothesis uhDef: Closest bo radix (ph+b)%R uh.
Hypothesis ulDef: (FtoRradix ul=ph+b-uh)%R.
Hypothesis tDef : Closest bo radix (uh-z)%R t.
Hypothesis vDef : Closest bo radix (pl+ul)%R v.
Hypothesis wDef : Closest bo radix (t+v)%R w.
Hypothesis Case2: ~(FtoRradix ul=0)%R.
Theorem ErrFmaApprox_2:(Rabs (z+w-(a*x+b)) <= (3*radix/2+/2)*powerRZ radix (2-2*p)*Rabs z)%R.
End uhInexact2.
Section Total.
Variable bo : Fbound.
Variable radix : Z.
Variable p : nat.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Hypothesis radixMoreThanOne : (1 < radix)%Z.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ radixMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Hypothesis pGivesBound : Zpos (vNum bo) = Zpower_nat radix p.
Hypothesis precisionGreaterThanOne : 4 <= p.
Variables a x b ph pl uh ul z t v w:float.
Hypothesis Fb: Fbounded bo b.
Hypothesis Fa: Fbounded bo a.
Hypothesis Fx: Fbounded bo x.
Hypothesis Nph: Fnormal radix bo ph \/ (FtoRradix ph=0).
Hypothesis Nuh: Fnormal radix bo uh \/ (FtoRradix uh=0).
Hypothesis Nz: Fnormal radix bo z \/ (FtoRradix z =0).
Hypothesis Nw: Fnormal radix bo w \/ (FtoRradix w =0).
Hypothesis Nv: Fnormal radix bo v \/ (FtoRradix v =0).
Hypothesis Exp1: (- dExp bo <= Fexp a+Fexp x)%Z.
Hypothesis zDef : Closest bo radix (a*x+b)%R z.
Hypothesis phDef: Closest bo radix (a*x)%R ph.
Hypothesis plDef: (FtoRradix pl=a*x-ph)%R.
Hypothesis uhDef: Closest bo radix (ph+b)%R uh.
Hypothesis ulDef: (FtoRradix ul=ph+b-uh)%R.
Hypothesis tDef : Closest bo radix (uh-z)%R t.
Hypothesis vDef : Closest bo radix (pl+ul)%R v.
Hypothesis wDef : Closest bo radix (t+v)%R w.
Theorem ErrFmaApprox:(Rabs (z+w-(a*x+b)) <= (3*radix/2+/2)*powerRZ radix (2-2*p)*Rabs z)%R.
End Total.
`