Average Error: 11.3 → 3.4
Time: 32.4s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
↓
\[\begin{array}{l}
\mathbf{if}\;a1 \cdot \frac{\frac{a2}{b2}}{b1} \le -8.325614965798377 \cdot 10^{+306}:\\
\;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\
\mathbf{if}\;a1 \cdot \frac{\frac{a2}{b2}}{b1} \le -3.771564587291262 \cdot 10^{-275}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\
\mathbf{if}\;a1 \cdot \frac{\frac{a2}{b2}}{b1} \le 1.8670147877566 \cdot 10^{-318}:\\
\;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\
\mathbf{if}\;a1 \cdot \frac{\frac{a2}{b2}}{b1} \le 4.6678838316786364 \cdot 10^{+289}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{a1}{b2} \cdot \frac{a2}{b1}} \cdot \sqrt{\frac{a1}{b2} \cdot \frac{a2}{b1}}\\
\end{array}\]
Try it out
Enter valid numbers for all inputs
Target
| Original | 11.3 |
|---|
| Target | 11.4 |
|---|
| Herbie | 3.4 |
|---|
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]
Derivation
- Split input into 4 regimes
if (* a1 (/ (/ a2 b2) b1)) < -8.325614965798377e+306
Initial program 15.7
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied associate-/r*9.2
\[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
if -8.325614965798377e+306 < (* a1 (/ (/ a2 b2) b1)) < -3.771564587291262e-275 or 1.8670147877566e-318 < (* a1 (/ (/ a2 b2) b1)) < 4.6678838316786364e+289
Initial program 14.5
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied div-inv14.8
\[\leadsto \color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}}\]
- Using strategy
rm Applied associate-*l*8.2
\[\leadsto \color{blue}{a1 \cdot \left(a2 \cdot \frac{1}{b1 \cdot b2}\right)}\]
Applied simplify0.9
\[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b2}}{b1}}\]
if -3.771564587291262e-275 < (* a1 (/ (/ a2 b2) b1)) < 1.8670147877566e-318
Initial program 4.6
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied div-inv4.6
\[\leadsto \color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}}\]
if 4.6678838316786364e+289 < (* a1 (/ (/ a2 b2) b1))
Initial program 14.4
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
- Using strategy
rm Applied div-inv15.4
\[\leadsto \color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}}\]
- Using strategy
rm Applied add-sqr-sqrt15.6
\[\leadsto \color{blue}{\sqrt{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}} \cdot \sqrt{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}}}\]
Applied simplify28.3
\[\leadsto \color{blue}{\sqrt{\frac{a1}{b2} \cdot \frac{a2}{b1}}} \cdot \sqrt{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}}\]
Applied simplify16.7
\[\leadsto \sqrt{\frac{a1}{b2} \cdot \frac{a2}{b1}} \cdot \color{blue}{\sqrt{\frac{a1}{b2} \cdot \frac{a2}{b1}}}\]
- Recombined 4 regimes into one program.
Runtime
herbie shell --seed 2018199
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))