\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 r148277 = x;
double r148278 = y;
double r148279 = r148277 - r148278;
double r148280 = r148277 + r148278;
double r148281 = r148279 * r148280;
double r148282 = r148277 * r148277;
double r148283 = r148278 * r148278;
double r148284 = r148282 + r148283;
double r148285 = r148281 / r148284;
return r148285;
}
double f(double x, double y) {
double r148286 = x;
double r148287 = y;
double r148288 = r148286 - r148287;
double r148289 = hypot(r148286, r148287);
double r148290 = r148286 + r148287;
double r148291 = r148289 / r148290;
double r148292 = r148289 * r148291;
double r148293 = r148288 / r148292;
return r148293;
}




Bits error versus x




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