\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;t_0 \leq -2.705684065734731 \cdot 10^{+245}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\
\mathbf{elif}\;t_0 \leq -7.6486 \cdot 10^{-320}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\frac{a1}{b2} \cdot \frac{a2}{b1}\\
\mathbf{elif}\;t_0 \leq 4.4178988718779176 \cdot 10^{+307}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a2}{b2}}{\frac{b1}{a1}}\\
\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 -2.705684065734731e+245)
(* a1 (/ (/ a2 b2) b1))
(if (<= t_0 -7.6486e-320)
t_0
(if (<= t_0 0.0)
(* (/ a1 b2) (/ a2 b1))
(if (<= t_0 4.4178988718779176e+307) t_0 (/ (/ a2 b2) (/ b1 a1))))))))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 <= -2.705684065734731e+245) {
tmp = a1 * ((a2 / b2) / b1);
} else if (t_0 <= -7.6486e-320) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = (a1 / b2) * (a2 / b1);
} else if (t_0 <= 4.4178988718779176e+307) {
tmp = t_0;
} else {
tmp = (a2 / b2) / (b1 / a1);
}
return tmp;
}




Bits error versus a1




Bits error versus a2




Bits error versus b1




Bits error versus b2
Results
| Original | 10.9 |
|---|---|
| Target | 11.2 |
| Herbie | 2.3 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -2.7056840657347309e245Initial program 40.3
Applied egg-rr18.0
Applied egg-rr17.5
Applied egg-rr19.1
if -2.7056840657347309e245 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -7.64863e-320 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 4.41789887187791757e307Initial program 0.7
if -7.64863e-320 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0Initial program 13.5
Applied egg-rr2.0
if 4.41789887187791757e307 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 64.0
Applied egg-rr4.6
Applied egg-rr4.4
Final simplification2.3
herbie shell --seed 2022130
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))