\frac{a1 \cdot a2}{b1 \cdot b2}\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -4.2694800775142445 \cdot 10^{+241}:\\
\;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\
\mathbf{elif}\;b1 \cdot b2 \leq -1.1223206066020718 \cdot 10^{-235}:\\
\;\;\;\;\frac{\frac{\sqrt[3]{a1} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{-b1 \cdot b2}}}{\sqrt[3]{\sqrt{-b1 \cdot b2}}} \cdot \left(\frac{\sqrt[3]{a1}}{\sqrt[3]{-b1 \cdot b2}} \cdot \left(-a2\right)\right)}{\sqrt[3]{\sqrt{-b1 \cdot b2}}}\\
\mathbf{elif}\;b1 \cdot b2 \leq 5.330746503442893 \cdot 10^{-288}:\\
\;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\
\mathbf{elif}\;b1 \cdot b2 \leq 7.94098457665328 \cdot 10^{+210}:\\
\;\;\;\;\frac{\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{-b1 \cdot b2}}}{\frac{\sqrt[3]{-b1 \cdot b2}}{\frac{\sqrt[3]{a1}}{\sqrt[3]{-b1 \cdot b2}} \cdot \left(-a2\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\end{array}(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
:precision binary64
(if (<= (* b1 b2) -4.2694800775142445e+241)
(/ (* a2 (/ a1 b1)) b2)
(if (<= (* b1 b2) -1.1223206066020718e-235)
(/
(*
(/
(* (cbrt a1) (/ (cbrt a1) (cbrt (- (* b1 b2)))))
(cbrt (sqrt (- (* b1 b2)))))
(* (/ (cbrt a1) (cbrt (- (* b1 b2)))) (- a2)))
(cbrt (sqrt (- (* b1 b2)))))
(if (<= (* b1 b2) 5.330746503442893e-288)
(/ (* a2 (/ a1 b1)) b2)
(if (<= (* b1 b2) 7.94098457665328e+210)
(/
(/ (* (cbrt a1) (cbrt a1)) (cbrt (- (* b1 b2))))
(/
(cbrt (- (* b1 b2)))
(* (/ (cbrt a1) (cbrt (- (* b1 b2)))) (- a2))))
(* (/ a1 b1) (/ a2 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 tmp;
if ((b1 * b2) <= -4.2694800775142445e+241) {
tmp = (a2 * (a1 / b1)) / b2;
} else if ((b1 * b2) <= -1.1223206066020718e-235) {
tmp = (((cbrt(a1) * (cbrt(a1) / cbrt(-(b1 * b2)))) / cbrt(sqrt(-(b1 * b2)))) * ((cbrt(a1) / cbrt(-(b1 * b2))) * -a2)) / cbrt(sqrt(-(b1 * b2)));
} else if ((b1 * b2) <= 5.330746503442893e-288) {
tmp = (a2 * (a1 / b1)) / b2;
} else if ((b1 * b2) <= 7.94098457665328e+210) {
tmp = ((cbrt(a1) * cbrt(a1)) / cbrt(-(b1 * b2))) / (cbrt(-(b1 * b2)) / ((cbrt(a1) / cbrt(-(b1 * b2))) * -a2));
} else {
tmp = (a1 / b1) * (a2 / 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.2 |
| Herbie | 2.9 |
| Alternative 1 | |
|---|---|
| Accuracy | 2.9 |
| Cost | 3140 |
| Alternative 2 | |
|---|---|
| Accuracy | 2.9 |
| Cost | 3078 |
| Alternative 3 | |
|---|---|
| Accuracy | 2.8 |
| Cost | 3078 |
| Alternative 4 | |
|---|---|
| Accuracy | 8.0 |
| Cost | 2752 |
| Alternative 5 | |
|---|---|
| Accuracy | 8.1 |
| Cost | 2816 |
| Alternative 6 | |
|---|---|
| Accuracy | 8.4 |
| Cost | 1856 |
| Alternative 7 | |
|---|---|
| Accuracy | 8.5 |
| Cost | 1856 |
| Alternative 8 | |
|---|---|
| Accuracy | 10.7 |
| Cost | 1600 |
if (*.f64 b1 b2) < -4.2694800775142445e241 or -1.1223206066020718e-235 < (*.f64 b1 b2) < 5.33074650344289276e-288Initial program 28.7
rmApplied associate-/r*_binary64_309111.4
Simplified4.9
if -4.2694800775142445e241 < (*.f64 b1 b2) < -1.1223206066020718e-235Initial program 4.6
rmApplied frac-2neg_binary64_31584.6
rmApplied add-cube-cbrt_binary64_31825.4
Applied associate-/r*_binary64_30915.4
Simplified5.1
rmApplied add-cube-cbrt_binary64_31825.3
Applied times-frac_binary64_31535.3
Applied associate-*l*_binary64_30882.6
Simplified2.6
rmApplied add-sqr-sqrt_binary64_31692.6
Applied cbrt-prod_binary64_31782.6
Applied associate-/r*_binary64_30912.6
Simplified1.9
if 5.33074650344289276e-288 < (*.f64 b1 b2) < 7.94098457665328e210Initial program 4.5
rmApplied frac-2neg_binary64_31584.5
rmApplied add-cube-cbrt_binary64_31825.4
Applied associate-/r*_binary64_30915.4
Simplified4.7
rmApplied add-cube-cbrt_binary64_31824.9
Applied times-frac_binary64_31534.9
Applied associate-*l*_binary64_30882.2
Simplified2.2
rmApplied associate-/l*_binary64_30922.1
if 7.94098457665328e210 < (*.f64 b1 b2) Initial program 15.8
rmApplied times-frac_binary64_31534.7
Final simplification2.9
herbie shell --seed 2020322
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))