\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -\infty:\\
\;\;\;\;\frac{1}{b1} \cdot \frac{a1}{\frac{1}{\frac{a2}{b2}}}\\
\mathbf{elif}\;b1 \cdot b2 \leq -4.072413297069987 \cdot 10^{-246}:\\
\;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\
\mathbf{elif}\;b1 \cdot b2 \leq 2.4232841084 \cdot 10^{-313}:\\
\;\;\;\;\left(a1 \cdot \frac{a2}{b1}\right) \cdot \frac{1}{b2}\\
\mathbf{elif}\;b1 \cdot b2 \leq 2.837907807204954 \cdot 10^{+169}:\\
\;\;\;\;\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 (<= (* b1 b2) (- INFINITY))
(* (/ 1.0 b1) (/ a1 (/ 1.0 (/ a2 b2))))
(if (<= (* b1 b2) -4.072413297069987e-246)
(* a1 (/ a2 (* b1 b2)))
(if (<= (* b1 b2) 2.4232841084e-313)
(* (* a1 (/ a2 b1)) (/ 1.0 b2))
(if (<= (* b1 b2) 2.837907807204954e+169)
(/ (* 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 ((b1 * b2) <= -((double) INFINITY)) {
tmp = (1.0 / b1) * (a1 / (1.0 / (a2 / b2)));
} else if ((b1 * b2) <= -4.072413297069987e-246) {
tmp = a1 * (a2 / (b1 * b2));
} else if ((b1 * b2) <= 2.4232841084e-313) {
tmp = (a1 * (a2 / b1)) * (1.0 / b2);
} else if ((b1 * b2) <= 2.837907807204954e+169) {
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.3 |
| Herbie | 5.1 |
if (*.f64 b1 b2) < -inf.0Initial program 23.4
Applied associate-/l*_binary6423.2
Simplified8.7
Applied div-inv_binary648.8
Applied *-un-lft-identity_binary648.8
Applied times-frac_binary642.1
if -inf.0 < (*.f64 b1 b2) < -4.07241329706998716e-246Initial program 5.1
Applied associate-/l*_binary644.8
Simplified10.7
Applied div-inv_binary6410.9
Simplified4.9
if -4.07241329706998716e-246 < (*.f64 b1 b2) < 2.42328410838e-313Initial program 50.9
Applied associate-/l*_binary6450.1
Simplified17.8
Applied associate-/r/_binary6417.6
Applied *-un-lft-identity_binary6417.6
Applied times-frac_binary648.8
Applied div-inv_binary648.8
Applied associate-*r*_binary648.6
Simplified8.5
if 2.42328410838e-313 < (*.f64 b1 b2) < 2.83790780720495407e169Initial program 5.5
if 2.83790780720495407e169 < (*.f64 b1 b2) Initial program 15.0
Applied associate-/l*_binary6414.1
Simplified8.2
Applied associate-/r/_binary648.1
Applied *-un-lft-identity_binary648.1
Applied times-frac_binary644.8
Simplified4.6
Final simplification5.1
herbie shell --seed 2022103
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))