\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{1}{b1} \cdot \left(a1 \cdot \frac{a2}{b2}\right)\\
\mathbf{elif}\;t_0 \leq -3.9477695 \cdot 10^{-316}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\
\mathbf{elif}\;t_0 \leq 2.848203589615897 \cdot 10^{+278}:\\
\;\;\;\;t_0\\
\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
(let* ((t_0 (/ (* a1 a2) (* b1 b2))))
(if (<= t_0 (- INFINITY))
(* (/ 1.0 b1) (* a1 (/ a2 b2)))
(if (<= t_0 -3.9477695e-316)
t_0
(if (<= t_0 0.0)
(* (/ a2 b2) (/ a1 b1))
(if (<= t_0 2.848203589615897e+278) t_0 (* (/ 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 t_0 = (a1 * a2) / (b1 * b2);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (1.0 / b1) * (a1 * (a2 / b2));
} else if (t_0 <= -3.9477695e-316) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = (a2 / b2) * (a1 / b1);
} else if (t_0 <= 2.848203589615897e+278) {
tmp = t_0;
} 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 | 10.9 |
|---|---|
| Target | 11.4 |
| Herbie | 2.5 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0Initial program 64.0
Applied associate-/l*_binary6430.0
Simplified17.6
Applied div-inv_binary6417.6
Applied *-un-lft-identity_binary6417.6
Applied times-frac_binary6419.7
Simplified19.7
if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -3.9477695e-316 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 2.8482035896158971e278Initial program 0.9
if -3.9477695e-316 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0Initial program 13.6
Applied times-frac_binary642.6
if 2.8482035896158971e278 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 57.0
Applied associate-/l*_binary6443.8
Simplified12.6
Applied associate-/r/_binary6411.8
Applied *-un-lft-identity_binary6411.8
Applied times-frac_binary648.2
Simplified8.1
Final simplification2.5
herbie shell --seed 2022068
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))