Average Error: 11.0 → 3.5
Time: 20.2s
Precision: 64
Internal Precision: 384
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;a1 \cdot \frac{a2}{b2} = -\infty:\\
\;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\
\mathbf{if}\;a1 \cdot \frac{a2}{b2} \le -2.4836944614157392 \cdot 10^{-278}:\\
\;\;\;\;\left(a1 \cdot \frac{a2}{b2}\right) \cdot \frac{1}{b1}\\
\mathbf{if}\;a1 \cdot \frac{a2}{b2} \le 1.3466206452563338 \cdot 10^{-300}:\\
\;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;a1 \cdot \frac{a2}{b2} \le 1.2267898782513618 \cdot 10^{+248}:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\
\end{array}\]
Target
| Original | 11.0 |
|---|
| Target | 11.1 |
|---|
| Herbie | 3.5 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 4 regimes
if (* a1 (/ a2 b2))
Initial program 14.5
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac35.5
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied div-inv35.5
\[\leadsto \frac{a1}{b1} \cdot \color{blue}{\left(a2 \cdot \frac{1}{b2}\right)}\]
Applied associate-*r*13.7
\[\leadsto \color{blue}{\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}}\]
if (* a1 (/ a2 b2)) < -2.4836944614157392e-278
Initial program 12.9
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac7.0
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied associate-*l/0.6
\[\leadsto \color{blue}{\frac{a1 \cdot \frac{a2}{b2}}{b1}}\]
- Using strategy
rm Applied div-inv0.6
\[\leadsto \color{blue}{\left(a1 \cdot \frac{a2}{b2}\right) \cdot \frac{1}{b1}}\]
if -2.4836944614157392e-278 < (* a1 (/ a2 b2)) < 1.3466206452563338e-300 or 1.2267898782513618e+248 < (* a1 (/ a2 b2))
Initial program 7.6
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
if 1.3466206452563338e-300 < (* a1 (/ a2 b2)) < 1.2267898782513618e+248
Initial program 12.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac7.3
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied associate-*l/0.5
\[\leadsto \color{blue}{\frac{a1 \cdot \frac{a2}{b2}}{b1}}\]
- Recombined 4 regimes into one program.
Runtime
herbie shell --seed '#(1064269945 2896236262 301053905 1701069080 1701464310 1614783279)'
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))