Average Error: 11.0 → 3.3
Time: 28.8s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.772316819689728 \cdot 10^{+308}:\\
\;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\
\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.2840847114569742 \cdot 10^{-227}:\\
\;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 4.4169219608089 \cdot 10^{-310}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.0223338474339116 \cdot 10^{+306}:\\
\;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a2}{b1}}{\frac{b2}{a1}}\\
\end{array}\]
Try it out
Enter valid numbers for all inputs
Target
| Original | 11.0 |
|---|
| Target | 11.0 |
|---|
| Herbie | 3.3 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 4 regimes
if (/ (* a1 a2) (* b1 b2)) < -1.772316819689728e+308
Initial program 59.9
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/l*28.4
\[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
if -1.772316819689728e+308 < (/ (* a1 a2) (* b1 b2)) < -1.2840847114569742e-227 or 4.4169219608089e-310 < (/ (* a1 a2) (* b1 b2)) < 1.0223338474339116e+306
Initial program 0.9
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
if -1.2840847114569742e-227 < (/ (* a1 a2) (* b1 b2)) < 4.4169219608089e-310
Initial program 11.9
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied times-frac4.0
\[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
if 1.0223338474339116e+306 < (/ (* a1 a2) (* b1 b2))
Initial program 60.7
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied clear-num60.6
\[\leadsto \color{blue}{\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}}\]
Taylor expanded around 0 60.6
\[\leadsto \frac{1}{\color{blue}{\frac{b1 \cdot b2}{a2 \cdot a1}}}\]
Applied simplify5.3
\[\leadsto \color{blue}{\frac{\frac{a2}{b1}}{\frac{b2}{a1}}}\]
- Recombined 4 regimes into one program.
Runtime
herbie shell --seed 2018208 +o rules:numerics
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))