\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)}{\left(x + y\right) \cdot 1}}double f(double x, double y) {
double r86685 = x;
double r86686 = y;
double r86687 = r86685 - r86686;
double r86688 = r86685 + r86686;
double r86689 = r86687 * r86688;
double r86690 = r86685 * r86685;
double r86691 = r86686 * r86686;
double r86692 = r86690 + r86691;
double r86693 = r86689 / r86692;
return r86693;
}
double f(double x, double y) {
double r86694 = x;
double r86695 = y;
double r86696 = r86694 - r86695;
double r86697 = hypot(r86694, r86695);
double r86698 = r86694 + r86695;
double r86699 = 1.0;
double r86700 = r86698 * r86699;
double r86701 = r86697 / r86700;
double r86702 = r86697 * r86701;
double r86703 = r86696 / r86702;
return r86703;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
Initial program 20.9
rmApplied associate-/l*21.0
rmApplied *-un-lft-identity21.0
Applied add-sqr-sqrt21.0
Applied times-frac21.0
Simplified21.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2020039 +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))))