Average Error: 10.6 → 3.1
Time: 31.6s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{a1}{b1 \cdot b2} = -\infty:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b1}}{b2}\\
\mathbf{if}\;\frac{a1}{b1 \cdot b2} \le -7.406698446546943 \cdot 10^{-308}:\\
\;\;\;\;\frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}\\
\mathbf{if}\;\frac{a1}{b1 \cdot b2} \le 2.44493325501 \cdot 10^{-319}:\\
\;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\
\mathbf{if}\;\frac{a1}{b1 \cdot b2} \le 2.4572370928044584 \cdot 10^{+201}:\\
\;\;\;\;\frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}\\
\mathbf{else}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b1}}{b2}\\
\end{array}\]
Target
| Original | 10.6 |
|---|
| Target | 11.4 |
|---|
| Herbie | 3.1 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (/ a1 (* b1 b2)) < -inf.0 or 2.4572370928044584e+201 < (/ a1 (* b1 b2))
Initial program 26.0
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*25.8
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
- Using strategy
rm Applied div-inv25.8
\[\leadsto \color{blue}{a1 \cdot \frac{1}{\frac{b1 \cdot b2}{a2}}}\]
Applied simplify25.7
\[\leadsto a1 \cdot \color{blue}{\frac{a2}{b1 \cdot b2}}\]
- Using strategy
rm Applied associate-/r*12.3
\[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b1}}{b2}}\]
if -inf.0 < (/ a1 (* b1 b2)) < -7.406698446546943e-308 or 2.44493325501e-319 < (/ a1 (* b1 b2)) < 2.4572370928044584e+201
Initial program 6.9
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*7.1
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
- Using strategy
rm Applied div-inv7.2
\[\leadsto \frac{a1}{\color{blue}{\left(b1 \cdot b2\right) \cdot \frac{1}{a2}}}\]
Applied associate-/r*0.6
\[\leadsto \color{blue}{\frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}}\]
if -7.406698446546943e-308 < (/ a1 (* b1 b2)) < 2.44493325501e-319
Initial program 12.9
\[\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 associate-/l*5.2
\[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1071215679 2002590028 935158157 1944352234 2656991306 2955288481)'
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))