\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.3404988451868662 \cdot 10^{154}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -5.69285947515511926 \cdot 10^{-160}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\mathbf{elif}\;y \le 1.2490407105203886 \cdot 10^{-166}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\end{array}double f(double x, double y) {
double r83926 = x;
double r83927 = y;
double r83928 = r83926 - r83927;
double r83929 = r83926 + r83927;
double r83930 = r83928 * r83929;
double r83931 = r83926 * r83926;
double r83932 = r83927 * r83927;
double r83933 = r83931 + r83932;
double r83934 = r83930 / r83933;
return r83934;
}
double f(double x, double y) {
double r83935 = y;
double r83936 = -1.3404988451868662e+154;
bool r83937 = r83935 <= r83936;
double r83938 = -1.0;
double r83939 = -5.692859475155119e-160;
bool r83940 = r83935 <= r83939;
double r83941 = x;
double r83942 = r83941 - r83935;
double r83943 = r83941 + r83935;
double r83944 = r83942 * r83943;
double r83945 = r83941 * r83941;
double r83946 = r83935 * r83935;
double r83947 = r83945 + r83946;
double r83948 = r83944 / r83947;
double r83949 = 1.2490407105203886e-166;
bool r83950 = r83935 <= r83949;
double r83951 = 1.0;
double r83952 = r83950 ? r83951 : r83948;
double r83953 = r83940 ? r83948 : r83952;
double r83954 = r83937 ? r83938 : r83953;
return r83954;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.2 |
|---|---|
| Target | 0.0 |
| Herbie | 5.0 |
if y < -1.3404988451868662e+154Initial program 64.0
Taylor expanded around 0 0
if -1.3404988451868662e+154 < y < -5.692859475155119e-160 or 1.2490407105203886e-166 < y Initial program 0.2
if -5.692859475155119e-160 < y < 1.2490407105203886e-166Initial program 30.1
Taylor expanded around inf 15.2
Final simplification5.0
herbie shell --seed 2020064 +o rules:numerics
(FPCore (x y)
:name "Kahan p9 Example"
:precision binary64
:pre (and (< 0.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))))