Average Error: 10.7 → 2.7
Time: 24.7s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1} = -\infty:\\
\;\;\;\;\frac{\frac{a1}{b1}}{b2} \cdot a2\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1} \le -1.3541215647845363 \cdot 10^{-224}:\\
\;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1} \le 1.4888223179164476 \cdot 10^{-282}:\\
\;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1} \le 1.8648617247277241 \cdot 10^{+279}:\\
\;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\
\mathbf{else}:\\
\;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\
\end{array}\]
Target
| Original | 10.7 |
|---|
| Target | 10.9 |
|---|
| Herbie | 2.7 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 4 regimes
if (/ (* a1 a2) b1) < -inf.0
Initial program 37.5
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*15.8
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
- Using strategy
rm Applied associate-/r/15.0
\[\leadsto \color{blue}{\frac{a1}{b1 \cdot b2} \cdot a2}\]
- Using strategy
rm Applied associate-/r*14.1
\[\leadsto \color{blue}{\frac{\frac{a1}{b1}}{b2}} \cdot a2\]
if -inf.0 < (/ (* a1 a2) b1) < -1.3541215647845363e-224 or 1.4888223179164476e-282 < (/ (* a1 a2) b1) < 1.8648617247277241e+279
Initial program 7.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/r*0.5
\[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
if -1.3541215647845363e-224 < (/ (* a1 a2) b1) < 1.4888223179164476e-282
Initial program 9.8
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*4.7
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
- Using strategy
rm Applied associate-/l*3.5
\[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
if 1.8648617247277241e+279 < (/ (* a1 a2) b1)
Initial program 31.1
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*11.9
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
- Using strategy
rm Applied div-inv12.3
\[\leadsto \color{blue}{a1 \cdot \frac{1}{\frac{b1 \cdot b2}{a2}}}\]
Applied simplify12.3
\[\leadsto a1 \cdot \color{blue}{\frac{a2}{b1 \cdot b2}}\]
- Recombined 4 regimes into one program.
Runtime
herbie shell --seed '#(1072107073 2127697367 3936270018 2300570620 2134894798 4023771849)' +o rules:numerics
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))