\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{x + y}{\mathsf{hypot}\left(x, y\right)}\right)\right)double f(double x, double y) {
double r2577642 = x;
double r2577643 = y;
double r2577644 = r2577642 - r2577643;
double r2577645 = r2577642 + r2577643;
double r2577646 = r2577644 * r2577645;
double r2577647 = r2577642 * r2577642;
double r2577648 = r2577643 * r2577643;
double r2577649 = r2577647 + r2577648;
double r2577650 = r2577646 / r2577649;
return r2577650;
}
double f(double x, double y) {
double r2577651 = x;
double r2577652 = y;
double r2577653 = r2577651 - r2577652;
double r2577654 = hypot(r2577651, r2577652);
double r2577655 = r2577653 / r2577654;
double r2577656 = r2577651 + r2577652;
double r2577657 = r2577656 / r2577654;
double r2577658 = r2577655 * r2577657;
double r2577659 = expm1(r2577658);
double r2577660 = log1p(r2577659);
return r2577660;
}




Bits error versus x




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