Average Error: 10.6 → 3.3
Time: 27.7s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;a1 \cdot \frac{a2}{b2} \le -8.88995106062109 \cdot 10^{+254}:\\
\;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\
\mathbf{if}\;a1 \cdot \frac{a2}{b2} \le -5.675069431468469 \cdot 10^{-284}:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\
\mathbf{if}\;a1 \cdot \frac{a2}{b2} \le 5.131113732319749 \cdot 10^{-257}:\\
\;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\
\mathbf{if}\;a1 \cdot \frac{a2}{b2} \le 1.7389567899629475 \cdot 10^{+218}:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\
\end{array}\]
Target
| Original | 10.6 |
|---|
| Target | 10.9 |
|---|
| Herbie | 3.3 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (* a1 (/ a2 b2)) < -8.88995106062109e+254 or 1.7389567899629475e+218 < (* a1 (/ a2 b2))
Initial program 15.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac27.5
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Using strategy
rm Applied div-inv27.5
\[\leadsto \frac{a1}{b1} \cdot \color{blue}{\left(a2 \cdot \frac{1}{b2}\right)}\]
Applied associate-*r*12.5
\[\leadsto \color{blue}{\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}}\]
if -8.88995106062109e+254 < (* a1 (/ a2 b2)) < -5.675069431468469e-284 or 5.131113732319749e-257 < (* a1 (/ a2 b2)) < 1.7389567899629475e+218
Initial program 12.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac7.2
\[\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}}\]
if -5.675069431468469e-284 < (* a1 (/ a2 b2)) < 5.131113732319749e-257
Initial program 5.1
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/r*4.7
\[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1071948828 1180510430 2986424009 997076509 406109801 420189285)'
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))