\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\frac{\frac{x - y}{\sqrt{x^2 + y^2}^*}}{\frac{\sqrt{x^2 + y^2}^*}{y + x}}double f(double x, double y) {
double r6750176 = x;
double r6750177 = y;
double r6750178 = r6750176 - r6750177;
double r6750179 = r6750176 + r6750177;
double r6750180 = r6750178 * r6750179;
double r6750181 = r6750176 * r6750176;
double r6750182 = r6750177 * r6750177;
double r6750183 = r6750181 + r6750182;
double r6750184 = r6750180 / r6750183;
return r6750184;
}
double f(double x, double y) {
double r6750185 = x;
double r6750186 = y;
double r6750187 = r6750185 - r6750186;
double r6750188 = hypot(r6750185, r6750186);
double r6750189 = r6750187 / r6750188;
double r6750190 = r6750186 + r6750185;
double r6750191 = r6750188 / r6750190;
double r6750192 = r6750189 / r6750191;
return r6750192;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.5 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 20.5
rmApplied associate-/l*20.5
rmApplied add-sqr-sqrt20.5
Applied associate-/l*20.4
rmApplied add-sqr-sqrt20.8
Applied *-un-lft-identity20.8
Applied times-frac20.8
Applied add-sqr-sqrt21.0
Applied times-frac21.1
Simplified20.8
Simplified0.0
rmApplied associate-/r*0.0
Final simplification0.0
herbie shell --seed 2019119 +o rules:numerics
(FPCore (x y)
:name "Kahan p9 Example"
:pre (and (< 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))))