\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{x - y}{\mathsf{hypot}\left(x, y\right)}}{\frac{\mathsf{hypot}\left(x, y\right)}{y + x}}\right)\right)double f(double x, double y) {
double r53867 = x;
double r53868 = y;
double r53869 = r53867 - r53868;
double r53870 = r53867 + r53868;
double r53871 = r53869 * r53870;
double r53872 = r53867 * r53867;
double r53873 = r53868 * r53868;
double r53874 = r53872 + r53873;
double r53875 = r53871 / r53874;
return r53875;
}
double f(double x, double y) {
double r53876 = x;
double r53877 = y;
double r53878 = r53876 - r53877;
double r53879 = hypot(r53876, r53877);
double r53880 = r53878 / r53879;
double r53881 = r53877 + r53876;
double r53882 = r53879 / r53881;
double r53883 = r53880 / r53882;
double r53884 = expm1(r53883);
double r53885 = log1p(r53884);
return r53885;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.1 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
Initial program 20.1
Simplified20.1
rmApplied add-sqr-sqrt20.1
Applied times-frac20.1
Simplified20.1
Simplified0.0
rmApplied log1p-expm1-u0.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2019195 +o rules:numerics
(FPCore (x y)
:name "Kahan p9 Example"
:pre (and (< 0.0 x 1.0) (< y 1.0))
:herbie-target
(if (< 0.5 (fabs (/ x y)) 2.0) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1.0 (/ 2.0 (+ 1.0 (* (/ x y) (/ x y))))))
(/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))