Average Error: 11.0 → 3.7
Time: 24.6s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2} = -\infty:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\
\mathbf{if}\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2} \le -9.8813129168249 \cdot 10^{-324}:\\
\;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\
\mathbf{if}\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2} \le 8.8931816251424 \cdot 10^{-323}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b1}}{b2}\\
\mathbf{if}\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2} \le 7.738380838434884 \cdot 10^{+272}:\\
\;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\
\mathbf{else}:\\
\;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\
\end{array}\]
Target
| Original | 11.0 |
|---|
| Target | 11.0 |
|---|
| Herbie | 3.7 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 4 regimes
if (* (* (/ a1 b1) a2) (/ 1 b2)) < -inf.0
Initial program 16.4
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac37.5
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied associate-*l/17.6
\[\leadsto \color{blue}{\frac{a1 \cdot \frac{a2}{b2}}{b1}}\]
if -inf.0 < (* (* (/ a1 b1) a2) (/ 1 b2)) < -9.8813129168249e-324 or 8.8931816251424e-323 < (* (* (/ a1 b1) a2) (/ 1 b2)) < 7.738380838434884e+272
Initial program 14.0
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac7.5
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied div-inv7.6
\[\leadsto \frac{a1}{b1} \cdot \color{blue}{\left(a2 \cdot \frac{1}{b2}\right)}\]
Applied associate-*r*0.9
\[\leadsto \color{blue}{\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}}\]
if -9.8813129168249e-324 < (* (* (/ a1 b1) a2) (/ 1 b2)) < 8.8931816251424e-323
Initial program 3.9
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac9.9
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied div-inv9.9
\[\leadsto \color{blue}{\left(a1 \cdot \frac{1}{b1}\right)} \cdot \frac{a2}{b2}\]
Applied associate-*l*4.2
\[\leadsto \color{blue}{a1 \cdot \left(\frac{1}{b1} \cdot \frac{a2}{b2}\right)}\]
Applied simplify4.6
\[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b1}}{b2}}\]
if 7.738380838434884e+272 < (* (* (/ a1 b1) a2) (/ 1 b2))
Initial program 16.7
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied div-inv17.4
\[\leadsto \color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}}\]
- Recombined 4 regimes into one program.
Runtime
herbie shell --seed '#(1071979731 1496239409 439705970 2863295848 982327776 189749553)'
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))