Average Error: 11.2 → 2.3
Time: 18.4s
Precision: 64
Internal Precision: 384
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;a1 \cdot \frac{a2}{b1} = -\infty:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\
\mathbf{if}\;a1 \cdot \frac{a2}{b1} \le -1.2338693843607816 \cdot 10^{-257}:\\
\;\;\;\;\left(a1 \cdot \frac{a2}{b1}\right) \cdot \frac{1}{b2}\\
\mathbf{if}\;a1 \cdot \frac{a2}{b1} \le -0.0:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\
\mathbf{if}\;a1 \cdot \frac{a2}{b1} \le 1.2405521163106836 \cdot 10^{+238}:\\
\;\;\;\;\left(a1 \cdot \frac{a2}{b1}\right) \cdot \frac{1}{b2}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\end{array}\]
Target
| Original | 11.2 |
|---|
| Target | 10.5 |
|---|
| Herbie | 2.3 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (* a1 (/ a2 b1)) or -1.2338693843607816e-257 < (* a1 (/ a2 b1)) < -0.0
Initial program 7.1
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac6.9
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied associate-*l/3.5
\[\leadsto \color{blue}{\frac{a1 \cdot \frac{a2}{b2}}{b1}}\]
if (* a1 (/ a2 b1)) < -1.2338693843607816e-257 or -0.0 < (* a1 (/ a2 b1)) < 1.2405521163106836e+238
Initial program 12.8
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac11.9
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied div-inv12.0
\[\leadsto \color{blue}{\left(a1 \cdot \frac{1}{b1}\right)} \cdot \frac{a2}{b2}\]
Applied associate-*l*12.7
\[\leadsto \color{blue}{a1 \cdot \left(\frac{1}{b1} \cdot \frac{a2}{b2}\right)}\]
Applied simplify7.1
\[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b1}}{b2}}\]
- Using strategy
rm Applied div-inv7.1
\[\leadsto a1 \cdot \color{blue}{\left(\frac{a2}{b1} \cdot \frac{1}{b2}\right)}\]
Applied associate-*r*0.6
\[\leadsto \color{blue}{\left(a1 \cdot \frac{a2}{b1}\right) \cdot \frac{1}{b2}}\]
if 1.2405521163106836e+238 < (* a1 (/ a2 b1))
Initial program 15.9
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac14.8
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1070258749 1877548225 2229079127 1588002776 3179087814 1886870650)'
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))