Average Error: 11.0 → 2.5
Time: 46.4s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\
\;\;\;\;\frac{\frac{a2}{\frac{b2}{a1}}}{b1}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -2.4371830820355918 \cdot 10^{-287}:\\
\;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 6.391630354180914 \cdot 10^{-290}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 8.034001747757763 \cdot 10^{+297}:\\
\;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\end{array}\]
Target
| Original | 11.0 |
|---|
| Target | 10.9 |
|---|
| Herbie | 2.5 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (/ (* a1 a2) (* b1 b2)) < -inf.0
Initial program 60.0
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/r*32.0
\[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
- Using strategy
rm Applied div-inv32.0
\[\leadsto \color{blue}{\frac{a1 \cdot a2}{b1} \cdot \frac{1}{b2}}\]
- Using strategy
rm Applied associate-*l/32.0
\[\leadsto \color{blue}{\frac{\left(a1 \cdot a2\right) \cdot \frac{1}{b2}}{b1}}\]
Applied simplify15.6
\[\leadsto \frac{\color{blue}{\frac{a2}{\frac{b2}{a1}}}}{b1}\]
if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -2.4371830820355918e-287 or 6.391630354180914e-290 < (/ (* a1 a2) (* b1 b2)) < 8.034001747757763e+297
Initial program 0.8
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied clear-num0.9
\[\leadsto \color{blue}{\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}}\]
if -2.4371830820355918e-287 < (/ (* a1 a2) (* b1 b2)) < 6.391630354180914e-290 or 8.034001747757763e+297 < (/ (* a1 a2) (* b1 b2))
Initial program 20.7
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac3.7
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1071373924 2949776965 1885069702 3247780810 90874544 2263903749)' +o rules:numerics
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))