\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\frac{x - y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{1}{\frac{\mathsf{hypot}\left(y, x\right)}{x + y}}double f(double x, double y) {
double r96464 = x;
double r96465 = y;
double r96466 = r96464 - r96465;
double r96467 = r96464 + r96465;
double r96468 = r96466 * r96467;
double r96469 = r96464 * r96464;
double r96470 = r96465 * r96465;
double r96471 = r96469 + r96470;
double r96472 = r96468 / r96471;
return r96472;
}
double f(double x, double y) {
double r96473 = x;
double r96474 = y;
double r96475 = r96473 - r96474;
double r96476 = hypot(r96474, r96473);
double r96477 = r96475 / r96476;
double r96478 = 1.0;
double r96479 = r96473 + r96474;
double r96480 = r96476 / r96479;
double r96481 = r96478 / r96480;
double r96482 = r96477 * r96481;
return r96482;
}




Bits error versus x




Bits error versus y
Results
| Original | 19.9 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 19.9
Simplified19.9
rmApplied add-sqr-sqrt19.9
Applied times-frac19.9
Simplified19.9
Simplified0.0
rmApplied clear-num0.0
Final simplification0.0
herbie shell --seed 2020045 +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))))