\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -2.8213046869993915 \cdot 10^{-161}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le 1.6059084603325851 \cdot 10^{-198}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{\sqrt{y \cdot y + x \cdot x}} \cdot \frac{y + x}{\sqrt{y \cdot y + x \cdot x}}\\
\end{array}double f(double x, double y) {
double r2140966 = x;
double r2140967 = y;
double r2140968 = r2140966 - r2140967;
double r2140969 = r2140966 + r2140967;
double r2140970 = r2140968 * r2140969;
double r2140971 = r2140966 * r2140966;
double r2140972 = r2140967 * r2140967;
double r2140973 = r2140971 + r2140972;
double r2140974 = r2140970 / r2140973;
return r2140974;
}
double f(double x, double y) {
double r2140975 = y;
double r2140976 = -2.8213046869993915e-161;
bool r2140977 = r2140975 <= r2140976;
double r2140978 = -1.0;
double r2140979 = 1.6059084603325851e-198;
bool r2140980 = r2140975 <= r2140979;
double r2140981 = 1.0;
double r2140982 = x;
double r2140983 = r2140982 - r2140975;
double r2140984 = r2140975 * r2140975;
double r2140985 = r2140982 * r2140982;
double r2140986 = r2140984 + r2140985;
double r2140987 = sqrt(r2140986);
double r2140988 = r2140983 / r2140987;
double r2140989 = r2140975 + r2140982;
double r2140990 = r2140989 / r2140987;
double r2140991 = r2140988 * r2140990;
double r2140992 = r2140980 ? r2140981 : r2140991;
double r2140993 = r2140977 ? r2140978 : r2140992;
return r2140993;
}




Bits error versus x




Bits error versus y
Results
| Original | 19.9 |
|---|---|
| Target | 0.1 |
| Herbie | 8.2 |
if y < -2.8213046869993915e-161Initial program 20.6
Taylor expanded around 0 5.6
if -2.8213046869993915e-161 < y < 1.6059084603325851e-198Initial program 29.7
Taylor expanded around -inf 14.2
if 1.6059084603325851e-198 < y Initial program 6.0
rmApplied add-sqr-sqrt6.0
Applied times-frac6.5
Final simplification8.2
herbie shell --seed 2019132
(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))))