\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\mathsf{expm1}\left(\mathsf{log1p}\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 r94080 = x;
double r94081 = y;
double r94082 = r94080 - r94081;
double r94083 = r94080 + r94081;
double r94084 = r94082 * r94083;
double r94085 = r94080 * r94080;
double r94086 = r94081 * r94081;
double r94087 = r94085 + r94086;
double r94088 = r94084 / r94087;
return r94088;
}
double f(double x, double y) {
double r94089 = x;
double r94090 = y;
double r94091 = r94089 - r94090;
double r94092 = hypot(r94089, r94090);
double r94093 = 1.0;
double r94094 = r94089 + r94090;
double r94095 = r94094 / r94092;
double r94096 = r94093 / r94095;
double r94097 = r94092 * r94096;
double r94098 = r94091 / r94097;
double r94099 = log1p(r94098);
double r94100 = expm1(r94099);
return r94100;
}




Bits error versus x




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