\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 r175517 = x;
double r175518 = y;
double r175519 = r175517 - r175518;
double r175520 = r175517 + r175518;
double r175521 = r175519 * r175520;
double r175522 = r175517 * r175517;
double r175523 = r175518 * r175518;
double r175524 = r175522 + r175523;
double r175525 = r175521 / r175524;
return r175525;
}
double f(double x, double y) {
double r175526 = x;
double r175527 = y;
double r175528 = r175526 - r175527;
double r175529 = hypot(r175526, r175527);
double r175530 = r175526 + r175527;
double r175531 = r175529 / r175530;
double r175532 = r175529 * r175531;
double r175533 = r175528 / r175532;
return r175533;
}




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))))