Average Error: 10.7 → 2.5
Time: 34.9s
Precision: 64
Internal Precision: 384
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{b1}{\frac{a2}{b2}} = -\infty:\\
\;\;\;\;\frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}\\
\mathbf{if}\;\frac{b1}{\frac{a2}{b2}} \le -4.5468445794146326 \cdot 10^{-214}:\\
\;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\
\mathbf{if}\;\frac{b1}{\frac{a2}{b2}} \le 1.3079441224287826 \cdot 10^{-284}:\\
\;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\
\mathbf{if}\;\frac{b1}{\frac{a2}{b2}} \le 1.284665394776019 \cdot 10^{+261}:\\
\;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\
\end{array}\]
Target
| Original | 10.7 |
|---|
| Target | 11.1 |
|---|
| Herbie | 2.5 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (/ b1 (/ a2 b2)) < -inf.0
Initial program 4.8
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*12.8
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
- Using strategy
rm Applied div-inv12.8
\[\leadsto \frac{a1}{\color{blue}{\left(b1 \cdot b2\right) \cdot \frac{1}{a2}}}\]
Applied associate-/r*4.9
\[\leadsto \color{blue}{\frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}}\]
if -inf.0 < (/ b1 (/ a2 b2)) < -4.5468445794146326e-214 or 1.3079441224287826e-284 < (/ b1 (/ a2 b2)) < 1.284665394776019e+261
Initial program 12.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*6.0
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
- Using strategy
rm Applied associate-/l*0.6
\[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
if -4.5468445794146326e-214 < (/ b1 (/ a2 b2)) < 1.3079441224287826e-284 or 1.284665394776019e+261 < (/ b1 (/ a2 b2))
Initial program 9.8
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/r*5.9
\[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1070386091 2509006183 1430610344 1025408621 36622005 1425925650)' +o rules:numerics
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))