\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 r99915 = x;
double r99916 = y;
double r99917 = r99915 - r99916;
double r99918 = r99915 + r99916;
double r99919 = r99917 * r99918;
double r99920 = r99915 * r99915;
double r99921 = r99916 * r99916;
double r99922 = r99920 + r99921;
double r99923 = r99919 / r99922;
return r99923;
}
double f(double x, double y) {
double r99924 = x;
double r99925 = y;
double r99926 = r99924 - r99925;
double r99927 = hypot(r99924, r99925);
double r99928 = r99924 + r99925;
double r99929 = r99927 / r99928;
double r99930 = r99927 * r99929;
double r99931 = r99926 / r99930;
return r99931;
}




Bits error versus x




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