\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\frac{\frac{x - y}{\mathsf{hypot}\left(x, y\right)}}{\frac{\mathsf{hypot}\left(x, y\right)}{x + y}}double f(double x, double y) {
double r87322 = x;
double r87323 = y;
double r87324 = r87322 - r87323;
double r87325 = r87322 + r87323;
double r87326 = r87324 * r87325;
double r87327 = r87322 * r87322;
double r87328 = r87323 * r87323;
double r87329 = r87327 + r87328;
double r87330 = r87326 / r87329;
return r87330;
}
double f(double x, double y) {
double r87331 = x;
double r87332 = y;
double r87333 = r87331 - r87332;
double r87334 = hypot(r87331, r87332);
double r87335 = r87333 / r87334;
double r87336 = r87331 + r87332;
double r87337 = r87334 / r87336;
double r87338 = r87335 / r87337;
return r87338;
}




Bits error versus x




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