\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\frac{1}{\frac{\frac{\mathsf{hypot}\left(x, y\right)}{x + y}}{\frac{x - y}{\mathsf{hypot}\left(x, y\right)}}}double f(double x, double y) {
double r156151 = x;
double r156152 = y;
double r156153 = r156151 - r156152;
double r156154 = r156151 + r156152;
double r156155 = r156153 * r156154;
double r156156 = r156151 * r156151;
double r156157 = r156152 * r156152;
double r156158 = r156156 + r156157;
double r156159 = r156155 / r156158;
return r156159;
}
double f(double x, double y) {
double r156160 = 1.0;
double r156161 = x;
double r156162 = y;
double r156163 = hypot(r156161, r156162);
double r156164 = r156161 + r156162;
double r156165 = r156163 / r156164;
double r156166 = r156161 - r156162;
double r156167 = r156166 / r156163;
double r156168 = r156165 / r156167;
double r156169 = r156160 / r156168;
return r156169;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.4 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 20.4
Simplified20.5
rmApplied *-un-lft-identity20.5
Applied add-sqr-sqrt20.6
Applied times-frac20.5
Simplified20.5
Simplified0.0
rmApplied log1p-expm1-u0.1
rmApplied clear-num0.1
Simplified0.0
Final simplification0.0
herbie shell --seed 2020033 +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))))