Average Error: 11.6 → 6.6
Time: 36.2s
Precision: 64
Internal precision: 128
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -4.333068901791902 \cdot 10^{-282}:\\
\;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 2.451390768683476 \cdot 10^{-38}:\\
\;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\end{array}\]
Target
| Original | 11.6 |
| Comparison | 10.8 |
| Herbie | 6.6 |
\[ \frac{a1}{b1} \cdot \frac{a2}{b2} \]
Derivation
- Split input into 4 regimes.
-
if (/ (* a1 a2) (* b1 b2)) < -4.333068901791902e-282
Initial program 7.5
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm
Applied div-inv 7.9
\[\leadsto \color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}}\]
if -4.333068901791902e-282 < (/ (* a1 a2) (* b1 b2)) < -0.0
Initial program 13.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm
Applied times-frac 2.8
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
if -0.0 < (/ (* a1 a2) (* b1 b2)) < 2.451390768683476e-38
Initial program 1.3
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm
Applied div-inv 1.4
\[\leadsto \color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}}\]
if 2.451390768683476e-38 < (/ (* a1 a2) (* b1 b2))
Initial program 19.9
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm
Applied times-frac 12.9
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Recombined 4 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1424593044 1042833029 2670409204 2315032527 2843787776 4023920578)'
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))