\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\frac{-\frac{x - y}{\frac{\mathsf{hypot}\left(x, y\right)}{x + y}}}{-\mathsf{hypot}\left(x, y\right)}double f(double x, double y) {
double r118383 = x;
double r118384 = y;
double r118385 = r118383 - r118384;
double r118386 = r118383 + r118384;
double r118387 = r118385 * r118386;
double r118388 = r118383 * r118383;
double r118389 = r118384 * r118384;
double r118390 = r118388 + r118389;
double r118391 = r118387 / r118390;
return r118391;
}
double f(double x, double y) {
double r118392 = x;
double r118393 = y;
double r118394 = r118392 - r118393;
double r118395 = hypot(r118392, r118393);
double r118396 = r118392 + r118393;
double r118397 = r118395 / r118396;
double r118398 = r118394 / r118397;
double r118399 = -r118398;
double r118400 = -r118395;
double r118401 = r118399 / r118400;
return r118401;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.0 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
Initial program 20.0
rmApplied add-sqr-sqrt20.0
Applied associate-/r*20.0
Simplified20.0
rmApplied frac-2neg20.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2020060 +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))))