\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.3381309335657303 \cdot 10^{+154}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.0184496907077957 \cdot 10^{-153}:\\
\;\;\;\;\frac{x \cdot x}{x \cdot x + y \cdot y} - \frac{y \cdot y}{x \cdot x + y \cdot y}\\
\mathbf{elif}\;y \le 3.4681229867935913 \cdot 10^{-162}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{x \cdot x + y \cdot y} - \frac{y \cdot y}{x \cdot x + y \cdot y}\\
\end{array}double f(double x, double y) {
double r2499004 = x;
double r2499005 = y;
double r2499006 = r2499004 - r2499005;
double r2499007 = r2499004 + r2499005;
double r2499008 = r2499006 * r2499007;
double r2499009 = r2499004 * r2499004;
double r2499010 = r2499005 * r2499005;
double r2499011 = r2499009 + r2499010;
double r2499012 = r2499008 / r2499011;
return r2499012;
}
double f(double x, double y) {
double r2499013 = y;
double r2499014 = -1.3381309335657303e+154;
bool r2499015 = r2499013 <= r2499014;
double r2499016 = -1.0;
double r2499017 = -1.0184496907077957e-153;
bool r2499018 = r2499013 <= r2499017;
double r2499019 = x;
double r2499020 = r2499019 * r2499019;
double r2499021 = r2499013 * r2499013;
double r2499022 = r2499020 + r2499021;
double r2499023 = r2499020 / r2499022;
double r2499024 = r2499021 / r2499022;
double r2499025 = r2499023 - r2499024;
double r2499026 = 3.4681229867935913e-162;
bool r2499027 = r2499013 <= r2499026;
double r2499028 = 1.0;
double r2499029 = r2499027 ? r2499028 : r2499025;
double r2499030 = r2499018 ? r2499025 : r2499029;
double r2499031 = r2499015 ? r2499016 : r2499030;
return r2499031;
}




Bits error versus x




Bits error versus y
Results
| Original | 19.8 |
|---|---|
| Target | 0.0 |
| Herbie | 5.1 |
if y < -1.3381309335657303e+154Initial program 63.6
Simplified63.6
Taylor expanded around -inf 63.6
Simplified63.6
Taylor expanded around 0 0
if -1.3381309335657303e+154 < y < -1.0184496907077957e-153 or 3.4681229867935913e-162 < y Initial program 0.0
Simplified0.0
Taylor expanded around -inf 0.0
Simplified0.0
if -1.0184496907077957e-153 < y < 3.4681229867935913e-162Initial program 28.6
Simplified28.6
Taylor expanded around -inf 28.6
Simplified28.6
Taylor expanded around inf 15.7
Final simplification5.1
herbie shell --seed 2019151
(FPCore (x y)
:name "Kahan p9 Example"
:pre (and (< 0 x 1) (< y 1))
:herbie-target
(if (< 0.5 (fabs (/ x y)) 2) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1 (/ 2 (+ 1 (* (/ x y) (/ x y))))))
(/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))