Library FArgReduct4
FArgReduct4 file
Sylvie Boldo
This file explains an improvement of Cody & Waite argument reduction technique using the FMA (fused-multiply-and-add).
Sylvie Boldo
This file explains an improvement of Cody & Waite argument reduction technique using the FMA (fused-multiply-and-add).
Require Export Dekker.
Require Export discriminant3.
Require Export FmaErr.
Require Export FArgReduct3.
Section Total.
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Variables
Variable b : Fbound.
Variables prec : nat.
Variable N : Z.
Variables alpha gamma x zH1 u gamma2 v res vL t1 t2: float.
Various bounds
Let bmoinsq :=
Bound
(P_of_succ_nat (pred (Zabs_nat (Zpower_nat radix (prec - 2)%nat))))
(dExp b).
All the hypotheses
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix prec.
Hypothesis Fboundedx : Fbounded b x.
Hypothesis xCanonic : Fcanonic radix b x.
Hypothesis xPos : (0 <= x)%R.
alpha (the constant, such as pi) and gamma (its inverse)
Hypothesis alphaNormal : Fnormal radix b alpha.
Hypothesis gammaNormal : Fnormal radix bmoinsq gamma.
Hypothesis alphaPos : (0 < alpha)%R.
Hypothesis gammaPos : (0 < gamma)%R.
Hypothesis
gamma_not_pow_2 : forall e : Z, FtoRradix gamma <> powerRZ radix e.
Hypothesis gammaDef : Closest bmoinsq radix (/ alpha) gamma.
About the computation of z
Hypothesis
uDef :
Closest b radix
(3%nat * powerRZ radix (Zpred (Zpred (prec - N))) + x * alpha) u.
Hypothesis
zH1Def :
Closest b radix (u - 3%nat * powerRZ radix (Zpred (Zpred (prec - N))))
zH1.
Hypothesis precMoreThanThree : 5 <= prec.
2^-N is a normal float
Hypothesis N_not_too_big : (N +prec -1 <= dExp b)%Z.
x not too big
Hypothesis
xalpha_small :
(x * alpha <=
powerRZ radix (Zpred (Zpred (prec - N))) - powerRZ radix (- N))%R.
No underflow
Hypothesis gamma_ge: (powerRZ radix (-dExp b+prec+(Zmax (-1) (prec+N-2)))<= gamma)%R.
gamma2 is the lower part of the constant
Hypothesis gamma2Bounded: Fbounded b gamma2.
Hypothesis gamma2_le: (Rabs gamma2 <= powerRZ radix (Fexp gamma))%R.
Hypothesis gamma2_e_eq: (Fexp gamma2 = Fexp gamma - prec+2)%Z.
v is the rounding of z gamma2 and vL the error
Hypothesis vDef : Closest b radix (zH1*gamma2)%R v.
Hypothesis vLDef: (FtoRradix vL=zH1*gamma2-v)%R.
Hypothesis vLBounded: Fbounded b vL.
t1 and t2 are the results of the FTS between v and (x-zH1*gamma)
Hypothesis t1Def: EvenClosest b radix prec (x-zH1*gamma-v)%R t1.
Hypothesis t2Def: (FtoRradix t2=x-zH1*gamma-v-t1)%R.
Hypothesis t2Bounded: Fbounded b t2.
res is the final result
Hypothesis resDef: EvenClosest b radix prec ((x-zH1*gamma)-zH1*gamma2)%R res.
Lemma Zmax_case: forall m n:Z,
((n <= m)%Z /\ Zmax m n=m) \/ ((m <= n)%Z /\ Zmax m n=n).
Lemma gamma_ge2: (powerRZ radix (-dExp b+prec+(Zmax (-1) N))<= gamma)%R.
Lemma exp_gamma_enough: (-dExp b <= Fexp gamma-prec-N)%Z.
Theorem Fexp_x_aprox_zh_gamma:
(0 < zH1)%R ->
(exists k:Z,
(powerRZ radix k <= zH1 < powerRZ radix (k+1))%R /\
(Fexp gamma+k-3 <= Fexp x)%Z /\ (-N <= k <= prec-3-N)%Z
/\ ((Fexp gamma-N-2 <= Fexp x)%Z \/ (FtoRradix zH1=powerRZ radix (-N))%R)).
Lemma zH_exp_N: exists f:float, (FtoRradix f=zH1)%R /\ Fbounded b f /\ (Fexp f=-N)%Z.
A Fast Two Sum can be used to compute the sum of the first
reduced argument and o(zH*gamma2)
Theorem FTS_correct_aux: ((FtoRradix zH1=0)%R\/(FtoRradix v=0)%R)
\/ exists ff:float,
FtoRradix ff = (x - zH1 * gamma)%R /\ Fbounded b ff /\
(Fexp (Fnormalize radix b prec v) <= -N + Fexp gamma -2)%Z /\
(-N + Fexp gamma -3 <= Fexp ff)%Z /\
(~(FtoRradix zH1) = powerRZ radix (-N)
-> (-N + Fexp gamma -2 <= Fexp ff)%Z) /\
((FtoRradix zH1) = powerRZ radix (-N)
-> (Fexp (Fnormalize radix b prec v) <= Fexp ff)%Z).
Theorem FTS_correct: ((FtoRradix zH1=0)%R\/(FtoRradix v=0)%R)
\/ exists ff:float,
FtoRradix ff = (x - zH1 * gamma)%R /\ Fbounded b ff /\
(Fexp (Fnormalize radix b prec v) <= Fexp ff)%Z.
Theorem v_neq_zero: (0 < zH1)%R -> (FtoRradix gamma2<>0)%R -> (FtoRradix v<>0)%R.
Theorem First_Comput_ok: exists f:float,
(FtoRradix f=t1-res)%R /\ Fbounded b f.
Theorem Second_Comput_ok:
exists f:float, (FtoRradix f=t1+t2-res)%R /\ Fbounded b f.
Lemma Farg_reduct_bounded_diff: forall (f1 f2 r:float),
Closest b radix (f1+f2) r
-> (- dExp b <= Fexp f2)%Z
-> (Fexp f2 <= Fexp f1)%Z
-> (Rabs (f1+f2) <= powerRZ radix (2*prec-1+(Fexp f2)))%R
-> exists g:float, (FtoRradix g=f1+f2-r)%R /\ Fbounded b g.
Theorem OneErrorOnly: ex (fun f : float =>
FtoRradix f = (x - zH1 * gamma -zH1*gamma2-res)%R /\ Fbounded b f).
End Total.
Section Gamma2Comput.
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Variables
Variable C : R.
Variable b : Fbound.
Variables prec : nat.
Variables alpha gamma gam2: float.
Various bounds
Let bmoinsq :=
Bound
(P_of_succ_nat (pred (Zabs_nat (Zpower_nat radix (prec - 2)%nat))))
(dExp b).
All the hypotheses
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix prec.
Hypothesis precMoreThanThree : 3 < prec.
Hypothesis CPos : (0 < C)%R.
Possible algorithm to get alpha and gamma
Hypothesis alphaDef : Closest b radix (/ C) alpha.
Hypothesis gammaDef : Closest bmoinsq radix (/ alpha) gamma.
Hypotheses on alpha and gamma
Hypothesis alphaNormal : Fnormal radix b alpha.
Hypothesis gammaNormal : Fnormal radix bmoinsq gamma.
Hypothesis alphaPos : (0 < alpha)%R.
Hypothesis gammaPos : (0 < gamma)%R.
Hypothesis
gamma_not_pow_2 : forall e : Z, FtoRradix gamma <> powerRZ radix e.
No Underflow
Hypothesis gamma_ge: (powerRZ radix (-dExp b+prec-1)<= gamma)%R.
Then C-gamma can be rounded in any way, it will be small enough
for the preceding theorems to hold. Note it also needs to be chopped
Theorem gamma2_le: (Rabs (C - gamma) <= powerRZ radix (Fexp gamma))%R.
End Gamma2Comput.