Average Error: 11.1 → 2.9
Time: 40.5s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{\frac{b1 \cdot b2}{a1}}{a2} \le -1.6951281669341966 \cdot 10^{+302}:\\
\;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\
\mathbf{if}\;\frac{\frac{b1 \cdot b2}{a1}}{a2} \le -5.324150171986738 \cdot 10^{-256}:\\
\;\;\;\;\frac{1}{\frac{\frac{b1 \cdot b2}{a1}}{a2}}\\
\mathbf{if}\;\frac{\frac{b1 \cdot b2}{a1}}{a2} \le 1.4509427417667148 \cdot 10^{-298}:\\
\;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\
\mathbf{if}\;\frac{\frac{b1 \cdot b2}{a1}}{a2} \le 4.406970769445578 \cdot 10^{+306}:\\
\;\;\;\;\frac{1}{\frac{\frac{b1 \cdot b2}{a1}}{a2}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\frac{a1 \cdot a2}{b1}}{b2}} \cdot \sqrt{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\\
\end{array}\]
Try it out
Enter valid numbers for all inputs
Target
| Original | 11.1 |
|---|
| Target | 11.0 |
|---|
| Herbie | 2.9 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 3 regimes
if (/ (/ (* b1 b2) a1) a2) < -1.6951281669341966e+302 or -5.324150171986738e-256 < (/ (/ (* b1 b2) a1) a2) < 1.4509427417667148e-298
Initial program 18.7
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/r*9.7
\[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
- Using strategy
rm Applied associate-/l*5.5
\[\leadsto \frac{\color{blue}{\frac{a1}{\frac{b1}{a2}}}}{b2}\]
if -1.6951281669341966e+302 < (/ (/ (* b1 b2) a1) a2) < -5.324150171986738e-256 or 1.4509427417667148e-298 < (/ (/ (* b1 b2) a1) a2) < 4.406970769445578e+306
Initial program 7.2
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied clear-num7.3
\[\leadsto \color{blue}{\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}}\]
- Using strategy
rm Applied associate-/r*1.1
\[\leadsto \frac{1}{\color{blue}{\frac{\frac{b1 \cdot b2}{a1}}{a2}}}\]
if 4.406970769445578e+306 < (/ (/ (* b1 b2) a1) a2)
Initial program 11.3
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/r*4.7
\[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
- Using strategy
rm Applied add-sqr-sqrt4.8
\[\leadsto \color{blue}{\sqrt{\frac{\frac{a1 \cdot a2}{b1}}{b2}} \cdot \sqrt{\frac{\frac{a1 \cdot a2}{b1}}{b2}}}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed 2018214 +o rules:numerics
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))