Average Error: 11.2 → 3.4
Time: 29.2s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{a1}{b2 \cdot \frac{b1}{a2}} = -\infty:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;\frac{a1}{b2 \cdot \frac{b1}{a2}} \le -2.3347233562848018 \cdot 10^{-306}:\\
\;\;\;\;\frac{a1}{b2 \cdot \frac{b1}{a2}}\\
\mathbf{if}\;\frac{a1}{b2 \cdot \frac{b1}{a2}} \le 0.0:\\
\;\;\;\;\frac{a1 \cdot a2}{b1} \cdot \frac{1}{b2}\\
\mathbf{if}\;\frac{a1}{b2 \cdot \frac{b1}{a2}} \le 8.390510085232154 \cdot 10^{+283}:\\
\;\;\;\;\frac{a1}{b2 \cdot \frac{b1}{a2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1 \cdot a2}{b1} \cdot \frac{1}{b2}\\
\end{array}\]
Target
| Original | 11.2 |
|---|
| Target | 11.1 |
|---|
| Herbie | 3.4 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (/ a1 (* b2 (/ b1 a2))) < -inf.0
Initial program 13.8
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac17.7
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
if -inf.0 < (/ a1 (* b2 (/ b1 a2))) < -2.3347233562848018e-306 or 0.0 < (/ a1 (* b2 (/ b1 a2))) < 8.390510085232154e+283
Initial program 14.6
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/r*14.1
\[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
- Using strategy
rm Applied associate-/l*7.5
\[\leadsto \frac{\color{blue}{\frac{a1}{\frac{b1}{a2}}}}{b2}\]
- Using strategy
rm Applied associate-/l/0.8
\[\leadsto \color{blue}{\frac{a1}{b2 \cdot \frac{b1}{a2}}}\]
if -2.3347233562848018e-306 < (/ a1 (* b2 (/ b1 a2))) < 0.0 or 8.390510085232154e+283 < (/ a1 (* b2 (/ b1 a2)))
Initial program 5.8
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/r*5.8
\[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
- Using strategy
rm Applied div-inv5.8
\[\leadsto \color{blue}{\frac{a1 \cdot a2}{b1} \cdot \frac{1}{b2}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1072840222 1305617769 1692503039 1353360431 4178980589 1488672652)'
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))