\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;t_0 \leq -8.466466328893688 \cdot 10^{+180}:\\
\;\;\;\;\frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}\\
\mathbf{elif}\;t_0 \leq -1.913926 \cdot 10^{-318}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 1.9964924777458289 \cdot 10^{-292}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{elif}\;t_0 \leq 3.336443235690429 \cdot 10^{+265}:\\
\;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1}{\frac{b2}{\frac{a2}{b1}}}\\
\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))))
(if (<= t_0 -8.466466328893688e+180)
(/ (/ a1 (* b1 b2)) (/ 1.0 a2))
(if (<= t_0 -1.913926e-318)
t_0
(if (<= t_0 1.9964924777458289e-292)
(* (/ a1 b1) (/ a2 b2))
(if (<= t_0 3.336443235690429e+265)
(/ 1.0 (/ (* b1 b2) (* a1 a2)))
(/ a1 (/ b2 (/ a2 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 t_0 = (a1 * a2) / (b1 * b2);
double tmp;
if (t_0 <= -8.466466328893688e+180) {
tmp = (a1 / (b1 * b2)) / (1.0 / a2);
} else if (t_0 <= -1.913926e-318) {
tmp = t_0;
} else if (t_0 <= 1.9964924777458289e-292) {
tmp = (a1 / b1) * (a2 / b2);
} else if (t_0 <= 3.336443235690429e+265) {
tmp = 1.0 / ((b1 * b2) / (a1 * a2));
} else {
tmp = a1 / (b2 / (a2 / b1));
}
return tmp;
}




Bits error versus a1




Bits error versus a2




Bits error versus b1




Bits error versus b2
Results
| Original | 11.2 |
|---|---|
| Target | 11.6 |
| Herbie | 4.0 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -8.46646632889368804e180Initial program 25.9
Applied associate-/l*_binary6419.7
Applied div-inv_binary6419.7
Applied associate-/r*_binary6419.4
Simplified19.4
if -8.46646632889368804e180 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.9139263e-318Initial program 1.0
Applied associate-/l*_binary646.5
Taylor expanded in a1 around 0 1.0
if -1.9139263e-318 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 1.99649247774582888e-292Initial program 13.3
Applied times-frac_binary642.5
if 1.99649247774582888e-292 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 3.3364432356904289e265Initial program 0.7
Applied clear-num_binary640.8
if 3.3364432356904289e265 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 53.9
Applied associate-/l*_binary6442.9
Applied div-inv_binary6442.9
Applied add-cube-cbrt_binary6443.2
Applied times-frac_binary6444.8
Applied frac-times_binary6443.2
Simplified42.9
Simplified42.9
Applied associate-/l*_binary6414.4
Final simplification4.0
herbie shell --seed 2022055
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))