\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{1}{\frac{x + y}{\mathsf{hypot}\left(x, y\right)}}}\right)\right)double f(double x, double y) {
double r87284 = x;
double r87285 = y;
double r87286 = r87284 - r87285;
double r87287 = r87284 + r87285;
double r87288 = r87286 * r87287;
double r87289 = r87284 * r87284;
double r87290 = r87285 * r87285;
double r87291 = r87289 + r87290;
double r87292 = r87288 / r87291;
return r87292;
}
double f(double x, double y) {
double r87293 = x;
double r87294 = y;
double r87295 = r87293 - r87294;
double r87296 = hypot(r87293, r87294);
double r87297 = 1.0;
double r87298 = r87293 + r87294;
double r87299 = r87298 / r87296;
double r87300 = r87297 / r87299;
double r87301 = r87296 * r87300;
double r87302 = r87295 / r87301;
double r87303 = expm1(r87302);
double r87304 = log1p(r87303);
return r87304;
}




Bits error versus x




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