\frac{a1 \cdot a2}{b1 \cdot b2}\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -1.027465146776261 \cdot 10^{+296}:\\
\;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\
\mathbf{elif}\;b1 \cdot b2 \leq -2.686121678391523 \cdot 10^{-295}:\\
\;\;\;\;\frac{a2 \cdot a1}{b1 \cdot b2}\\
\mathbf{elif}\;b1 \cdot b2 \leq 1.7361396809959 \cdot 10^{-311}:\\
\;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\
\mathbf{elif}\;b1 \cdot b2 \leq 7.874769199228514 \cdot 10^{+270}:\\
\;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\
\end{array}(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
:precision binary64
(if (<= (* b1 b2) -1.027465146776261e+296)
(/ (* a2 (/ a1 b1)) b2)
(if (<= (* b1 b2) -2.686121678391523e-295)
(/ (* a2 a1) (* b1 b2))
(if (<= (* b1 b2) 1.7361396809959e-311)
(/ (* a2 (/ a1 b1)) b2)
(if (<= (* b1 b2) 7.874769199228514e+270)
(/ a1 (/ (* b1 b2) a2))
(/ (/ a1 (/ b1 a2)) 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 ((b1 * b2) <= -1.027465146776261e+296) {
tmp = (a2 * (a1 / b1)) / b2;
} else if ((b1 * b2) <= -2.686121678391523e-295) {
tmp = (a2 * a1) / (b1 * b2);
} else if ((b1 * b2) <= 1.7361396809959e-311) {
tmp = (a2 * (a1 / b1)) / b2;
} else if ((b1 * b2) <= 7.874769199228514e+270) {
tmp = a1 / ((b1 * b2) / a2);
} else {
tmp = (a1 / (b1 / a2)) / 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.4 |
| Herbie | 5.3 |
if (*.f64 b1 b2) < -1.02746514677626109e296 or -2.6861216783915232e-295 < (*.f64 b1 b2) < 1.73613968099587e-311Initial program 36.8
rmApplied associate-/r*_binary64_581913.3
Simplified4.8
if -1.02746514677626109e296 < (*.f64 b1 b2) < -2.6861216783915232e-295Initial program 5.8
if 1.73613968099587e-311 < (*.f64 b1 b2) < 7.8747691992285138e270Initial program 5.6
rmApplied associate-/l*_binary64_58205.5
if 7.8747691992285138e270 < (*.f64 b1 b2) Initial program 20.5
rmApplied associate-/r*_binary64_58199.6
Simplified3.7
Taylor expanded around 0 9.6
rmApplied associate-/l*_binary64_58203.8
Final simplification5.3
herbie shell --seed 2021059
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))