Average Error: 10.6 → 3.9
Time: 33.7s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{b1}{\frac{a2}{b2}} \le -2.45747023661579 \cdot 10^{+162}:\\
\;\;\;\;\frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}\\
\mathbf{if}\;\frac{b1}{\frac{a2}{b2}} \le -2.289325936129236 \cdot 10^{-277}:\\
\;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\
\mathbf{if}\;\frac{b1}{\frac{a2}{b2}} \le 9.67115627877642 \cdot 10^{-306}:\\
\;\;\;\;\frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}\\
\mathbf{if}\;\frac{b1}{\frac{a2}{b2}} \le 2.1083299968523078 \cdot 10^{+293}:\\
\;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\
\mathbf{else}:\\
\;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\
\end{array}\]
Target
| Original | 10.6 |
|---|
| Target | 11.4 |
|---|
| Herbie | 3.9 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (/ b1 (/ a2 b2)) < -2.45747023661579e+162 or -2.289325936129236e-277 < (/ b1 (/ a2 b2)) < 9.67115627877642e-306
Initial program 9.3
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*18.5
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
- Using strategy
rm Applied div-inv18.5
\[\leadsto \frac{a1}{\color{blue}{\left(b1 \cdot b2\right) \cdot \frac{1}{a2}}}\]
Applied associate-/r*9.6
\[\leadsto \color{blue}{\frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}}\]
if -2.45747023661579e+162 < (/ b1 (/ a2 b2)) < -2.289325936129236e-277 or 9.67115627877642e-306 < (/ b1 (/ a2 b2)) < 2.1083299968523078e+293
Initial program 12.5
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*6.1
\[\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 2.1083299968523078e+293 < (/ b1 (/ a2 b2))
Initial program 5.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied div-inv5.3
\[\leadsto \color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1071215679 2002590028 935158157 1944352234 2656991306 2955288481)' +o rules:numerics
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))