\frac{a1 \cdot a2}{b1 \cdot b2}\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\
\;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\
\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -5.7805680563426 \cdot 10^{-322} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 1.3879797649998844 \cdot 10^{-268}\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 1.041374688326402 \cdot 10^{+308}:\\
\;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\
\end{array}(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
:precision binary64
(if (<= (/ (* a1 a2) (* b1 b2)) (- INFINITY))
(/ (* a2 (/ a1 b1)) b2)
(if (or (<= (/ (* a1 a2) (* b1 b2)) -5.7805680563426e-322)
(and (not (<= (/ (* a1 a2) (* b1 b2)) 1.3879797649998844e-268))
(<= (/ (* a1 a2) (* b1 b2)) 1.041374688326402e+308)))
(/ (* a1 a2) (* b1 b2))
(* (/ a2 b1) (/ a1 b2)))))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 tmp;
if (((a1 * a2) / (b1 * b2)) <= -((double) INFINITY)) {
tmp = (a2 * (a1 / b1)) / b2;
} else if ((((a1 * a2) / (b1 * b2)) <= -5.7805680563426e-322) || (!(((a1 * a2) / (b1 * b2)) <= 1.3879797649998844e-268) && (((a1 * a2) / (b1 * b2)) <= 1.041374688326402e+308))) {
tmp = (a1 * a2) / (b1 * b2);
} else {
tmp = (a2 / b1) * (a1 / b2);
}
return tmp;
}




Bits error versus a1




Bits error versus a2




Bits error versus b1




Bits error versus b2
Results
| Original | 11.7 |
|---|---|
| Target | 11.2 |
| Herbie | 2.7 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0Initial program 64.0
rmApplied associate-/r*_binary64_271937.2
Simplified19.0
if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -5.78057e-322 or 1.3879797649998844e-268 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 1.04137468832640207e308Initial program 0.9
if -5.78057e-322 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 1.3879797649998844e-268 or 1.04137468832640207e308 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 22.2
rmApplied associate-/l*_binary64_272014.7
Simplified5.4
rmApplied associate-/r/_binary64_27215.9
Applied *-un-lft-identity_binary64_27735.9
Applied times-frac_binary64_27793.8
Simplified3.7
Final simplification2.7
herbie shell --seed 2020303
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))