\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;t_0 \leq -1.078471501403316 \cdot 10^{+259}:\\
\;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\
\mathbf{elif}\;t_0 \leq -1.9812476037083025 \cdot 10^{-288}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\frac{\frac{a1}{b2}}{\frac{b1}{a2}}\\
\mathbf{elif}\;t_0 \leq 2.8284868700362058 \cdot 10^{+298}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\
\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 -1.078471501403316e+259)
(/ (/ a1 (/ b1 a2)) b2)
(if (<= t_0 -1.9812476037083025e-288)
t_0
(if (<= t_0 0.0)
(/ (/ a1 b2) (/ b1 a2))
(if (<= t_0 2.8284868700362058e+298) t_0 (/ (/ a1 b1) (/ b2 a2))))))))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 <= -1.078471501403316e+259) {
tmp = (a1 / (b1 / a2)) / b2;
} else if (t_0 <= -1.9812476037083025e-288) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = (a1 / b2) / (b1 / a2);
} else if (t_0 <= 2.8284868700362058e+298) {
tmp = t_0;
} else {
tmp = (a1 / b1) / (b2 / a2);
}
return tmp;
}




Bits error versus a1




Bits error versus a2




Bits error versus b1




Bits error versus b2
Results
| Original | 10.7 |
|---|---|
| Target | 11.3 |
| Herbie | 2.7 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.07847150140331607e259Initial program 41.8
Applied associate-/r*_binary6425.9
Applied associate-/l*_binary6418.0
if -1.07847150140331607e259 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.98124760370830246e-288 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 2.8284868700362058e298Initial program 0.8
if -1.98124760370830246e-288 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0Initial program 12.6
Applied associate-/r*_binary646.4
Applied associate-/l*_binary643.8
Applied associate-/l/_binary644.2
Applied associate-/r*_binary642.7
if 2.8284868700362058e298 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 60.9
Applied associate-/r*_binary6447.4
Applied associate-/l*_binary6414.5
Applied associate-/r/_binary6414.3
Applied associate-/l*_binary647.8
Final simplification2.7
herbie shell --seed 2022077
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))