Average Error: 10.3 → 3.5
Time: 22.4s
Precision: 64
Internal Precision: 384
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1} = -\infty:\\
\;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1} \le -1.3132924252388058 \cdot 10^{-300}:\\
\;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1} \le 1.0631791320686 \cdot 10^{-313}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;\frac{a1 \cdot a2}{b1} \le 2.9865402441518893 \cdot 10^{+192}:\\
\;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\
\mathbf{else}:\\
\;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\
\end{array}\]
Target
| Original | 10.3 |
|---|
| Target | 11.0 |
|---|
| Herbie | 3.5 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (/ (* a1 a2) b1) or 2.9865402441518893e+192 < (/ (* a1 a2) b1)
Initial program 26.5
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*13.3
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
if (/ (* a1 a2) b1) < -1.3132924252388058e-300 or 1.0631791320686e-313 < (/ (* a1 a2) b1) < 2.9865402441518893e+192
Initial program 6.7
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/r*0.6
\[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
if -1.3132924252388058e-300 < (/ (* a1 a2) b1) < 1.0631791320686e-313
Initial program 11.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac5.7
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1064300848 3212030778 2049303162 3567222883 2277747821 1384278011)'
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))