\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_1 := \frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;t_0 \leq -5.0856438256446027 \cdot 10^{+222}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -5.6645791 \cdot 10^{-316}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 4.373228051816653 \cdot 10^{+239}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{b1 \cdot \frac{b2}{a1}}\\
\end{array}
(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 (* (/ a1 b1) (/ a2 b2))))
(if (<= t_0 -5.0856438256446027e+222)
t_1
(if (<= t_0 -5.6645791e-316)
t_0
(if (<= t_0 0.0)
t_1
(if (<= t_0 4.373228051816653e+239) t_0 (/ a2 (* b1 (/ b2 a1)))))))))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 = (a1 / b1) * (a2 / b2);
double tmp;
if (t_0 <= -5.0856438256446027e+222) {
tmp = t_1;
} else if (t_0 <= -5.6645791e-316) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 4.373228051816653e+239) {
tmp = t_0;
} else {
tmp = a2 / (b1 * (b2 / a1));
}
return tmp;
}




Bits error versus a1




Bits error versus a2




Bits error versus b1




Bits error versus b2
Results
| Original | 11.2 |
|---|---|
| Target | 11.3 |
| Herbie | 3.5 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -5.0856438256446027e222 or -5.664579081e-316 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0Initial program 16.9
Applied times-frac_binary644.6
if -5.0856438256446027e222 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -5.664579081e-316 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 4.37322805181665277e239Initial program 0.8
if 4.37322805181665277e239 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 48.7
Applied associate-/r*_binary6440.3
Simplified15.0
Applied associate-/l*_binary6415.0
Applied associate-/r/_binary6415.2
Final simplification3.5
herbie shell --seed 2022020
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))