\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;t_0 \leq -3.490612777261886 \cdot 10^{+283}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b1}}{b2}\\
\mathbf{elif}\;t_0 \leq -1.166 \cdot 10^{-321}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{elif}\;t_0 \leq 8.02086535294186 \cdot 10^{+252}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a2}{b1}}{\frac{b2}{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 -3.490612777261886e+283)
(* a1 (/ (/ a2 b1) b2))
(if (<= t_0 -1.166e-321)
t_0
(if (<= t_0 0.0)
(* (/ a1 b1) (/ a2 b2))
(if (<= t_0 8.02086535294186e+252) t_0 (/ (/ a2 b1) (/ b2 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 <= -3.490612777261886e+283) {
tmp = a1 * ((a2 / b1) / b2);
} else if (t_0 <= -1.166e-321) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = (a1 / b1) * (a2 / b2);
} else if (t_0 <= 8.02086535294186e+252) {
tmp = t_0;
} else {
tmp = (a2 / b1) / (b2 / a1);
}
return tmp;
}




Bits error versus a1




Bits error versus a2




Bits error versus b1




Bits error versus b2
Results
| Original | 11.3 |
|---|---|
| Target | 11.1 |
| Herbie | 2.7 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -3.49061277726188584e283Initial program 53.2
Applied egg-rr27.9
Applied egg-rr16.6
if -3.49061277726188584e283 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.16599e-321 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 8.0208653529418605e252Initial program 0.8
Applied egg-rr17.1
Applied egg-rr0.8
if -1.16599e-321 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0Initial program 13.1
Applied egg-rr2.2
if 8.0208653529418605e252 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 52.3
Applied egg-rr9.5
Applied egg-rr9.4
Final simplification2.7
herbie shell --seed 2022129
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))