\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 r72640 = x;
double r72641 = y;
double r72642 = r72640 - r72641;
double r72643 = r72640 + r72641;
double r72644 = r72642 * r72643;
double r72645 = r72640 * r72640;
double r72646 = r72641 * r72641;
double r72647 = r72645 + r72646;
double r72648 = r72644 / r72647;
return r72648;
}
double f(double x, double y) {
double r72649 = x;
double r72650 = y;
double r72651 = r72649 - r72650;
double r72652 = hypot(r72649, r72650);
double r72653 = r72651 / r72652;
double r72654 = 1.0;
double r72655 = r72649 + r72650;
double r72656 = r72652 / r72655;
double r72657 = r72654 / r72656;
double r72658 = r72653 * r72657;
return r72658;
}




Bits error versus x




Bits error versus y
Results
| Original | 19.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
Initial program 19.9
rmApplied add-sqr-sqrt19.9
Applied times-frac20.0
Simplified20.0
Simplified0.0
rmApplied clear-num0.0
Final simplification0.0
herbie shell --seed 2019323 +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))))