\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 r78734 = x;
double r78735 = y;
double r78736 = r78734 - r78735;
double r78737 = r78734 + r78735;
double r78738 = r78736 * r78737;
double r78739 = r78734 * r78734;
double r78740 = r78735 * r78735;
double r78741 = r78739 + r78740;
double r78742 = r78738 / r78741;
return r78742;
}
double f(double x, double y) {
double r78743 = x;
double r78744 = y;
double r78745 = r78743 - r78744;
double r78746 = hypot(r78743, r78744);
double r78747 = r78745 / r78746;
double r78748 = 1.0;
double r78749 = r78743 + r78744;
double r78750 = r78746 / r78749;
double r78751 = r78748 / r78750;
double r78752 = r78747 * r78751;
return r78752;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.2 |
|---|---|
| Target | 0.1 |
| 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 2019199 +o rules:numerics
(FPCore (x y)
:name "Kahan p9 Example"
:pre (and (< 0.0 x 1.0) (< y 1.0))
:herbie-target
(if (< 0.5 (fabs (/ x y)) 2.0) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1.0 (/ 2.0 (+ 1.0 (* (/ x y) (/ x y))))))
(/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))