\frac{a1 \cdot a2}{b1 \cdot b2}\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -2.283272658395434 \cdot 10^{+115}:\\
\;\;\;\;\frac{\frac{a2}{b2}}{\frac{1}{\frac{a1}{b1}}}\\
\mathbf{elif}\;b1 \cdot b2 \leq -4.1009444647243185 \cdot 10^{-261}:\\
\;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\
\mathbf{elif}\;b1 \cdot b2 \leq 7.617741858679191 \cdot 10^{-212}:\\
\;\;\;\;\frac{\frac{a2 \cdot a1}{b1}}{b2}\\
\mathbf{elif}\;b1 \cdot b2 \leq 6.200897575910236 \cdot 10^{+291}:\\
\;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a2}{b2}}{\frac{1}{\frac{a1}{b1}}}\\
\end{array}(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
:precision binary64
(if (<= (* b1 b2) -2.283272658395434e+115)
(/ (/ a2 b2) (/ 1.0 (/ a1 b1)))
(if (<= (* b1 b2) -4.1009444647243185e-261)
(* a2 (/ a1 (* b1 b2)))
(if (<= (* b1 b2) 7.617741858679191e-212)
(/ (/ (* a2 a1) b1) b2)
(if (<= (* b1 b2) 6.200897575910236e+291)
(/ a1 (/ (* b1 b2) a2))
(/ (/ a2 b2) (/ 1.0 (/ a1 b1))))))))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 ((b1 * b2) <= -2.283272658395434e+115) {
tmp = (a2 / b2) / (1.0 / (a1 / b1));
} else if ((b1 * b2) <= -4.1009444647243185e-261) {
tmp = a2 * (a1 / (b1 * b2));
} else if ((b1 * b2) <= 7.617741858679191e-212) {
tmp = ((a2 * a1) / b1) / b2;
} else if ((b1 * b2) <= 6.200897575910236e+291) {
tmp = a1 / ((b1 * b2) / a2);
} else {
tmp = (a2 / b2) / (1.0 / (a1 / b1));
}
return tmp;
}




Bits error versus a1




Bits error versus a2




Bits error versus b1




Bits error versus b2
Results
| Original | 11.4 |
|---|---|
| Target | 11.2 |
| Herbie | 6.3 |
if (*.f64 b1 b2) < -2.28328e115 or 6.20091e291 < (*.f64 b1 b2) Initial program 15.7
rmApplied times-frac_binary64_5695.0
rmApplied associate-*r/_binary64_6355.3
Simplified5.3
rmApplied associate-/l*_binary64_6387.9
rmApplied div-inv_binary64_5758.0
Applied associate-/r*_binary64_6375.3
if -2.28328e115 < (*.f64 b1 b2) < -4.10091e-261Initial program 5.1
rmApplied times-frac_binary64_56916.2
rmApplied associate-*r/_binary64_63516.0
Simplified16.0
rmApplied *-un-lft-identity_binary64_57416.0
Applied times-frac_binary64_56912.5
Simplified12.5
Simplified4.8
if -4.10091e-261 < (*.f64 b1 b2) < 7.61774e-212Initial program 38.7
rmApplied associate-/r*_binary64_63717.9
Simplified17.9
if 7.61774e-212 < (*.f64 b1 b2) < 6.20091e291Initial program 5.3
rmApplied associate-/l*_binary64_6385.0
Final simplification6.3
herbie shell --seed 2020231
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))