\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_1 := \frac{a2}{b1} \cdot \frac{a1}{b2}\\
\mathbf{if}\;t_0 \leq -4.038047391351627 \cdot 10^{+281}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -3.3157554142466014 \cdot 10^{-276}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 7.694643325017655 \cdot 10^{+299}:\\
\;\;\;\;\frac{a1 \cdot a2}{\frac{b1}{\frac{1}{b2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\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))) (t_1 (* (/ a2 b1) (/ a1 b2))))
(if (<= t_0 -4.038047391351627e+281)
t_1
(if (<= t_0 -3.3157554142466014e-276)
t_0
(if (<= t_0 0.0)
t_1
(if (<= t_0 7.694643325017655e+299)
(/ (* a1 a2) (/ b1 (/ 1.0 b2)))
(* (/ 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 t_0 = (a1 * a2) / (b1 * b2);
double t_1 = (a2 / b1) * (a1 / b2);
double tmp;
if (t_0 <= -4.038047391351627e+281) {
tmp = t_1;
} else if (t_0 <= -3.3157554142466014e-276) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 7.694643325017655e+299) {
tmp = (a1 * a2) / (b1 / (1.0 / b2));
} 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.6 |
|---|---|
| Target | 11.3 |
| Herbie | 2.5 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -4.03804739135162685e281 or -3.3157554142466014e-276 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0Initial program 18.1
Applied associate-/l*_binary6410.1
Simplified5.8
Applied associate-/r/_binary645.7
Applied *-un-lft-identity_binary645.7
Applied times-frac_binary644.4
Simplified4.2
if -4.03804739135162685e281 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -3.3157554142466014e-276Initial program 0.7
if 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 7.6946433250176545e299Initial program 1.0
Applied associate-/l*_binary648.4
Simplified14.7
Applied div-inv_binary6414.8
Applied *-un-lft-identity_binary6414.8
Applied times-frac_binary648.5
Applied associate-/r*_binary641.1
Simplified1.0
if 7.6946433250176545e299 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 61.9
Applied times-frac_binary646.8
Final simplification2.5
herbie shell --seed 2021310
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))