\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\begin{array}{l}
\mathbf{if}\;\left(y \cdot 4\right) \cdot y \le 3.555296387473610131894589033479720995539 \cdot 10^{-320}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(1\right)\right)\\
\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 6.796343694084571001073879733570555857418 \cdot 10^{-30}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\\
\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 346611751697267904479232:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(1\right)\right)\\
\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 3.303575063990275761709788655917798036004 \cdot 10^{146}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\mathsf{fma}\left(x, x, -\left(y \cdot 4\right) \cdot y\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}double f(double x, double y) {
double r804991 = x;
double r804992 = r804991 * r804991;
double r804993 = y;
double r804994 = 4.0;
double r804995 = r804993 * r804994;
double r804996 = r804995 * r804993;
double r804997 = r804992 - r804996;
double r804998 = r804992 + r804996;
double r804999 = r804997 / r804998;
return r804999;
}
double f(double x, double y) {
double r805000 = y;
double r805001 = 4.0;
double r805002 = r805000 * r805001;
double r805003 = r805002 * r805000;
double r805004 = 3.5552963874736e-320;
bool r805005 = r805003 <= r805004;
double r805006 = 1.0;
double r805007 = expm1(r805006);
double r805008 = log1p(r805007);
double r805009 = 6.796343694084571e-30;
bool r805010 = r805003 <= r805009;
double r805011 = x;
double r805012 = fma(r805011, r805011, r805003);
double r805013 = r805011 * r805011;
double r805014 = r805013 - r805003;
double r805015 = r805012 / r805014;
double r805016 = r805006 / r805015;
double r805017 = 3.466117516972679e+23;
bool r805018 = r805003 <= r805017;
double r805019 = 3.3035750639902758e+146;
bool r805020 = r805003 <= r805019;
double r805021 = -r805003;
double r805022 = fma(r805011, r805011, r805021);
double r805023 = r805013 + r805003;
double r805024 = r805022 / r805023;
double r805025 = expm1(r805024);
double r805026 = log1p(r805025);
double r805027 = -1.0;
double r805028 = r805020 ? r805026 : r805027;
double r805029 = r805018 ? r805008 : r805028;
double r805030 = r805010 ? r805016 : r805029;
double r805031 = r805005 ? r805008 : r805030;
return r805031;
}




Bits error versus x




Bits error versus y
| Original | 32.2 |
|---|---|
| Target | 31.8 |
| Herbie | 13.6 |
if (* (* y 4.0) y) < 3.5552963874736e-320 or 6.796343694084571e-30 < (* (* y 4.0) y) < 3.466117516972679e+23Initial program 28.7
rmApplied log1p-expm1-u28.7
Taylor expanded around inf 11.2
if 3.5552963874736e-320 < (* (* y 4.0) y) < 6.796343694084571e-30Initial program 16.4
rmApplied clear-num16.4
Simplified16.4
if 3.466117516972679e+23 < (* (* y 4.0) y) < 3.3035750639902758e+146Initial program 17.7
rmApplied log1p-expm1-u17.7
rmApplied fma-neg17.7
if 3.3035750639902758e+146 < (* (* y 4.0) y) Initial program 47.9
Taylor expanded around 0 12.7
Final simplification13.6
herbie shell --seed 2019354 +o rules:numerics
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< (/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4))) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4)))) 2) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))))
(/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))))