\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{x - y}{\mathsf{hypot}\left(y, x\right)}}{\log \left(e^{\frac{\mathsf{hypot}\left(y, x\right)}{y + x}}\right)}\right)\right)double f(double x, double y) {
double r2031848 = x;
double r2031849 = y;
double r2031850 = r2031848 - r2031849;
double r2031851 = r2031848 + r2031849;
double r2031852 = r2031850 * r2031851;
double r2031853 = r2031848 * r2031848;
double r2031854 = r2031849 * r2031849;
double r2031855 = r2031853 + r2031854;
double r2031856 = r2031852 / r2031855;
return r2031856;
}
double f(double x, double y) {
double r2031857 = x;
double r2031858 = y;
double r2031859 = r2031857 - r2031858;
double r2031860 = hypot(r2031858, r2031857);
double r2031861 = r2031859 / r2031860;
double r2031862 = r2031858 + r2031857;
double r2031863 = r2031860 / r2031862;
double r2031864 = exp(r2031863);
double r2031865 = log(r2031864);
double r2031866 = r2031861 / r2031865;
double r2031867 = log1p(r2031866);
double r2031868 = expm1(r2031867);
return r2031868;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.3 |
|---|---|
| Target | 0.0 |
| Herbie | 0.1 |
Initial program 20.3
Simplified20.3
rmApplied add-sqr-sqrt20.3
Applied times-frac20.4
rmApplied expm1-log1p-u20.6
Simplified0.0
rmApplied add-log-exp0.1
Final simplification0.1
herbie shell --seed 2019141 +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))))