Average Error: 11.6 → 3.6
Time: 28.1s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{a1}{\frac{b1}{a2}} \le -1.0538430783977041 \cdot 10^{+248}:\\
\;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\
\mathbf{if}\;\frac{a1}{\frac{b1}{a2}} \le -3.069604403649267 \cdot 10^{-275}:\\
\;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\
\mathbf{if}\;\frac{a1}{\frac{b1}{a2}} \le 3.085021802936852 \cdot 10^{-290}:\\
\;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\
\mathbf{if}\;\frac{a1}{\frac{b1}{a2}} \le 2.1922187956608556 \cdot 10^{+205}:\\
\;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\end{array}\]
Target
| Original | 11.6 |
|---|
| Target | 11.1 |
|---|
| Herbie | 3.6 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 4 regimes
if (/ a1 (/ b1 a2)) < -1.0538430783977041e+248
Initial program 16.3
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*12.0
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
if -1.0538430783977041e+248 < (/ a1 (/ b1 a2)) < -3.069604403649267e-275 or 3.085021802936852e-290 < (/ a1 (/ b1 a2)) < 2.1922187956608556e+205
Initial program 13.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*13.5
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
- Using strategy
rm Applied associate-/l*13.4
\[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
- Using strategy
rm Applied associate-/r/7.5
\[\leadsto \frac{a1}{\color{blue}{\frac{b1}{a2} \cdot b2}}\]
Applied associate-/r*0.5
\[\leadsto \color{blue}{\frac{\frac{a1}{\frac{b1}{a2}}}{b2}}\]
if -3.069604403649267e-275 < (/ a1 (/ b1 a2)) < 3.085021802936852e-290
Initial program 6.1
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*5.6
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
- Using strategy
rm Applied div-inv5.6
\[\leadsto \color{blue}{a1 \cdot \frac{1}{\frac{b1 \cdot b2}{a2}}}\]
Applied simplify5.3
\[\leadsto a1 \cdot \color{blue}{\frac{a2}{b1 \cdot b2}}\]
if 2.1922187956608556e+205 < (/ a1 (/ b1 a2))
Initial program 15.5
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac15.6
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Recombined 4 regimes into one program.
Runtime
herbie shell --seed '#(1072330854 3074818769 591214268 3603999196 3863745332 3332387116)' +o rules:numerics
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))