\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_1 := \frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -1.0778478930048488 \cdot 10^{-249}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 1.154926780129537 \cdot 10^{+270}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b1}}{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 (* (/ a1 b1) (/ a2 b2))))
(if (<= t_0 (- INFINITY))
t_1
(if (<= t_0 -1.0778478930048488e-249)
t_0
(if (<= t_0 0.0)
t_1
(if (<= t_0 1.154926780129537e+270) t_0 (/ (* a1 (/ a2 b1)) 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 = (a1 / b1) * (a2 / b2);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= -1.0778478930048488e-249) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 1.154926780129537e+270) {
tmp = t_0;
} else {
tmp = (a1 * (a2 / b1)) / b2;
}
return tmp;
}




Bits error versus a1




Bits error versus a2




Bits error versus b1




Bits error versus b2
Results
| Original | 11.3 |
|---|---|
| Target | 11.5 |
| Herbie | 3.2 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0 or -1.0778478930048488e-249 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0Initial program 16.8
Applied times-frac_binary644.3
if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.0778478930048488e-249 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 1.15492678012953692e270Initial program 0.8
if 1.15492678012953692e270 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 55.6
Applied associate-/r*_binary6445.1
Applied *-un-lft-identity_binary6445.1
Applied times-frac_binary6414.5
Simplified14.5
Final simplification3.2
herbie shell --seed 2022066
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))