Average Error: 10.9 → 3.6
Time: 48.9s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -3.299015055999917 \cdot 10^{+294}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -2.495598836304291 \cdot 10^{-308}:\\
\;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.2197391025701286 \cdot 10^{-308}:\\
\;\;\;\;\frac{\frac{1}{\frac{b1}{a1 \cdot a2}}}{b2}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 2.1300160425759017 \cdot 10^{+281}:\\
\;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\end{array}\]
Try it out
Enter valid numbers for all inputs
Target
| Original | 10.9 |
|---|
| Target | 10.7 |
|---|
| Herbie | 3.6 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (/ (* a1 a2) (* b1 b2)) < -3.299015055999917e+294 or 2.1300160425759017e+281 < (/ (* a1 a2) (* b1 b2))
Initial program 53.8
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac8.1
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
if -3.299015055999917e+294 < (/ (* a1 a2) (* b1 b2)) < -2.495598836304291e-308 or 1.2197391025701286e-308 < (/ (* a1 a2) (* b1 b2)) < 2.1300160425759017e+281
Initial program 0.9
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied div-inv1.3
\[\leadsto \color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}}\]
if -2.495598836304291e-308 < (/ (* a1 a2) (* b1 b2)) < 1.2197391025701286e-308
Initial program 13.9
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/r*6.2
\[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
- Using strategy
rm Applied clear-num6.2
\[\leadsto \frac{\color{blue}{\frac{1}{\frac{b1}{a1 \cdot a2}}}}{b2}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed 2019053 +o rules:numerics
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))