\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 r757568 = x;
double r757569 = y;
double r757570 = r757568 - r757569;
double r757571 = r757568 + r757569;
double r757572 = r757570 * r757571;
double r757573 = r757568 * r757568;
double r757574 = r757569 * r757569;
double r757575 = r757573 + r757574;
double r757576 = r757572 / r757575;
return r757576;
}
double f(double x, double y) {
double r757577 = x;
double r757578 = y;
double r757579 = r757577 - r757578;
double r757580 = hypot(r757577, r757578);
double r757581 = r757577 + r757578;
double r757582 = r757580 / r757581;
double r757583 = r757579 / r757582;
double r757584 = r757583 / r757580;
return r757584;
}




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 hypot-def0.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))))