\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -2.35356263340194646 \cdot 10^{-113}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le 7.03047708396554176 \cdot 10^{-131}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}double f(double x, double y) {
double r54022 = x;
double r54023 = y;
double r54024 = r54022 - r54023;
double r54025 = r54022 + r54023;
double r54026 = r54024 * r54025;
double r54027 = r54022 * r54022;
double r54028 = r54023 * r54023;
double r54029 = r54027 + r54028;
double r54030 = r54026 / r54029;
return r54030;
}
double f(double __attribute__((unused)) x, double y) {
double r54031 = y;
double r54032 = -2.3535626334019465e-113;
bool r54033 = r54031 <= r54032;
double r54034 = -1.0;
double r54035 = 7.030477083965542e-131;
bool r54036 = r54031 <= r54035;
double r54037 = 1.0;
double r54038 = r54036 ? r54037 : r54034;
double r54039 = r54033 ? r54034 : r54038;
return r54039;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.6 |
|---|---|
| Target | 0.0 |
| Herbie | 11.0 |
if y < -2.3535626334019465e-113 or 7.030477083965542e-131 < y Initial program 18.5
Simplified18.1
Taylor expanded around 0 5.7
if -2.3535626334019465e-113 < y < 7.030477083965542e-131Initial program 23.6
Simplified24.7
Taylor expanded around inf 18.8
Final simplification11.0
herbie shell --seed 2020046
(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))))