\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{1}{\frac{\mathsf{hypot}\left(x, y\right)}{x + y}}double f(double x, double y) {
double r88863 = x;
double r88864 = y;
double r88865 = r88863 - r88864;
double r88866 = r88863 + r88864;
double r88867 = r88865 * r88866;
double r88868 = r88863 * r88863;
double r88869 = r88864 * r88864;
double r88870 = r88868 + r88869;
double r88871 = r88867 / r88870;
return r88871;
}
double f(double x, double y) {
double r88872 = x;
double r88873 = y;
double r88874 = r88872 - r88873;
double r88875 = hypot(r88872, r88873);
double r88876 = r88874 / r88875;
double r88877 = 1.0;
double r88878 = r88872 + r88873;
double r88879 = r88875 / r88878;
double r88880 = r88877 / r88879;
double r88881 = r88876 * r88880;
return r88881;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.2 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 20.2
rmApplied add-sqr-sqrt20.2
Applied times-frac20.3
Simplified20.2
Simplified0.0
rmApplied clear-num0.0
Final simplification0.0
herbie shell --seed 2019351 +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))))