(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
:precision binary64
(let* ((t_0 (/ (* a1 a2) (* b1 b2))) (t_1 (* (/ 1.0 (/ b1 a2)) (/ a1 b2))))
(if (<= t_0 -1.040164306635014e+306)
t_1
(if (<= t_0 -7.4e-323)
t_0
(if (<= t_0 0.0) t_1 (if (<= t_0 6.474204089623792e+306) t_0 t_1))))))double code(double a1, double a2, double b1, double b2) {
return (a1 * a2) / (b1 * b2);
}
double code(double a1, double a2, double b1, double b2) {
double t_0 = (a1 * a2) / (b1 * b2);
double t_1 = (1.0 / (b1 / a2)) * (a1 / b2);
double tmp;
if (t_0 <= -1.040164306635014e+306) {
tmp = t_1;
} else if (t_0 <= -7.4e-323) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 6.474204089623792e+306) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a1, a2, b1, b2)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: b1
real(8), intent (in) :: b2
code = (a1 * a2) / (b1 * b2)
end function
real(8) function code(a1, a2, b1, b2)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: b1
real(8), intent (in) :: b2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (a1 * a2) / (b1 * b2)
t_1 = (1.0d0 / (b1 / a2)) * (a1 / b2)
if (t_0 <= (-1.040164306635014d+306)) then
tmp = t_1
else if (t_0 <= (-7.4d-323)) then
tmp = t_0
else if (t_0 <= 0.0d0) then
tmp = t_1
else if (t_0 <= 6.474204089623792d+306) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a1, double a2, double b1, double b2) {
return (a1 * a2) / (b1 * b2);
}
public static double code(double a1, double a2, double b1, double b2) {
double t_0 = (a1 * a2) / (b1 * b2);
double t_1 = (1.0 / (b1 / a2)) * (a1 / b2);
double tmp;
if (t_0 <= -1.040164306635014e+306) {
tmp = t_1;
} else if (t_0 <= -7.4e-323) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 6.474204089623792e+306) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a1, a2, b1, b2): return (a1 * a2) / (b1 * b2)
def code(a1, a2, b1, b2): t_0 = (a1 * a2) / (b1 * b2) t_1 = (1.0 / (b1 / a2)) * (a1 / b2) tmp = 0 if t_0 <= -1.040164306635014e+306: tmp = t_1 elif t_0 <= -7.4e-323: tmp = t_0 elif t_0 <= 0.0: tmp = t_1 elif t_0 <= 6.474204089623792e+306: tmp = t_0 else: tmp = t_1 return tmp
function code(a1, a2, b1, b2) return Float64(Float64(a1 * a2) / Float64(b1 * b2)) end
function code(a1, a2, b1, b2) t_0 = Float64(Float64(a1 * a2) / Float64(b1 * b2)) t_1 = Float64(Float64(1.0 / Float64(b1 / a2)) * Float64(a1 / b2)) tmp = 0.0 if (t_0 <= -1.040164306635014e+306) tmp = t_1; elseif (t_0 <= -7.4e-323) tmp = t_0; elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 6.474204089623792e+306) tmp = t_0; else tmp = t_1; end return tmp end
function tmp = code(a1, a2, b1, b2) tmp = (a1 * a2) / (b1 * b2); end
function tmp_2 = code(a1, a2, b1, b2) t_0 = (a1 * a2) / (b1 * b2); t_1 = (1.0 / (b1 / a2)) * (a1 / b2); tmp = 0.0; if (t_0 <= -1.040164306635014e+306) tmp = t_1; elseif (t_0 <= -7.4e-323) tmp = t_0; elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 6.474204089623792e+306) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a1_, a2_, b1_, b2_] := N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]
code[a1_, a2_, b1_, b2_] := Block[{t$95$0 = N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 / N[(b1 / a2), $MachinePrecision]), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1.040164306635014e+306], t$95$1, If[LessEqual[t$95$0, -7.4e-323], t$95$0, If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 6.474204089623792e+306], t$95$0, t$95$1]]]]]]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_1 := \frac{1}{\frac{b1}{a2}} \cdot \frac{a1}{b2}\\
\mathbf{if}\;t_0 \leq -1.040164306635014 \cdot 10^{+306}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -7.4 \cdot 10^{-323}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 6.474204089623792 \cdot 10^{+306}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus a1




Bits error versus a2




Bits error versus b1




Bits error versus b2
Results
| Original | 11.3 |
|---|---|
| Target | 11.1 |
| Herbie | 2.1 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.040164306635014e306 or -7.41098e-323 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0 or 6.4742040896237921e306 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 26.1
Simplified15.8
Applied egg-rr6.5
Applied egg-rr3.9
if -1.040164306635014e306 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -7.41098e-323 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 6.4742040896237921e306Initial program 0.7
Simplified7.7
Applied egg-rr14.1
Taylor expanded in a1 around 0 0.7
Final simplification2.1
herbie shell --seed 2022153
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))