Average Error: 11.0 → 2.6
Time: 22.2s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{b1 \cdot b2}{a2} = -\infty:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\
\mathbf{if}\;\frac{b1 \cdot b2}{a2} \le -4.5506165736991245 \cdot 10^{-257}:\\
\;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\
\mathbf{if}\;\frac{b1 \cdot b2}{a2} \le 6.448832594176252 \cdot 10^{-308}:\\
\;\;\;\;\frac{1}{\frac{b2}{\frac{a1}{b1} \cdot a2}}\\
\mathbf{if}\;\frac{b1 \cdot b2}{a2} \le 2.684224932606484 \cdot 10^{+283}:\\
\;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\
\end{array}\]
Target
| Original | 11.0 |
|---|
| Target | 11.0 |
|---|
| Herbie | 2.6 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (/ (* b1 b2) a2) < -inf.0 or 2.684224932606484e+283 < (/ (* b1 b2) a2)
Initial program 13.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac5.5
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied associate-*l/5.6
\[\leadsto \color{blue}{\frac{a1 \cdot \frac{a2}{b2}}{b1}}\]
if -inf.0 < (/ (* b1 b2) a2) < -4.5506165736991245e-257 or 6.448832594176252e-308 < (/ (* b1 b2) a2) < 2.684224932606484e+283
Initial program 7.3
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*0.5
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
if -4.5506165736991245e-257 < (/ (* b1 b2) a2) < 6.448832594176252e-308
Initial program 30.5
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac15.3
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied associate-*r/8.9
\[\leadsto \color{blue}{\frac{\frac{a1}{b1} \cdot a2}{b2}}\]
- Using strategy
rm Applied clear-num9.0
\[\leadsto \color{blue}{\frac{1}{\frac{b2}{\frac{a1}{b1} \cdot a2}}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1072361757 3390613284 2339397988 1175251238 145061547 3101881848)' +o rules:numerics
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))