\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{\mathsf{hypot}\left(x, y\right)}{x + y}}double f(double x, double y) {
double r85828 = x;
double r85829 = y;
double r85830 = r85828 - r85829;
double r85831 = r85828 + r85829;
double r85832 = r85830 * r85831;
double r85833 = r85828 * r85828;
double r85834 = r85829 * r85829;
double r85835 = r85833 + r85834;
double r85836 = r85832 / r85835;
return r85836;
}
double f(double x, double y) {
double r85837 = x;
double r85838 = y;
double r85839 = r85837 - r85838;
double r85840 = hypot(r85837, r85838);
double r85841 = r85837 + r85838;
double r85842 = r85840 / r85841;
double r85843 = r85840 * r85842;
double r85844 = r85839 / r85843;
return r85844;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.3 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
Initial program 20.3
Simplified20.3
rmApplied *-un-lft-identity20.3
Applied add-sqr-sqrt20.3
Applied times-frac20.3
Simplified20.3
Simplified0.0
Final simplification0.0
herbie shell --seed 2020081 +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))))