Average Error: 10.4 → 3.1
Time: 20.4s
Precision: 64
Internal Precision: 384
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{a1}{b1} \cdot \frac{a2}{b2} = -\infty:\\
\;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\
\mathbf{if}\;\frac{a1}{b1} \cdot \frac{a2}{b2} \le -4.2497434639426 \cdot 10^{-313}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;\frac{a1}{b1} \cdot \frac{a2}{b2} \le 3.162020133384 \cdot 10^{-322}:\\
\;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\
\mathbf{if}\;\frac{a1}{b1} \cdot \frac{a2}{b2} \le 1.7288020775202732 \cdot 10^{+226}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{else}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b1}}{b2}\\
\end{array}\]
Target
| Original | 10.4 |
|---|
| Target | 10.9 |
|---|
| Herbie | 3.1 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (* (/ a1 b1) (/ a2 b2)) < -inf.0 or -4.2497434639426e-313 < (* (/ a1 b1) (/ a2 b2)) < 3.162020133384e-322
Initial program 2.8
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied clear-num3.2
\[\leadsto \color{blue}{\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}}\]
if -inf.0 < (* (/ a1 b1) (/ a2 b2)) < -4.2497434639426e-313 or 3.162020133384e-322 < (* (/ a1 b1) (/ a2 b2)) < 1.7288020775202732e+226
Initial program 15.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac0.8
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
if 1.7288020775202732e+226 < (* (/ a1 b1) (/ a2 b2))
Initial program 10.6
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac44.2
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied div-inv44.2
\[\leadsto \color{blue}{\left(a1 \cdot \frac{1}{b1}\right)} \cdot \frac{a2}{b2}\]
Applied associate-*l*35.6
\[\leadsto \color{blue}{a1 \cdot \left(\frac{1}{b1} \cdot \frac{a2}{b2}\right)}\]
Applied simplify15.1
\[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b1}}{b2}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1070609872 3456127585 2380521889 2328837196 1765472538 734540918)'
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))