\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -3.2350588066957499 \cdot 10^{153}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(-1\right)\right)\\
\mathbf{elif}\;y \le -7.33106158512129338 \cdot 10^{-158}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\right)\right)\\
\mathbf{elif}\;y \le 1.3645633303893502 \cdot 10^{-189}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\right)\right)\\
\end{array}double f(double x, double y) {
double r68568 = x;
double r68569 = y;
double r68570 = r68568 - r68569;
double r68571 = r68568 + r68569;
double r68572 = r68570 * r68571;
double r68573 = r68568 * r68568;
double r68574 = r68569 * r68569;
double r68575 = r68573 + r68574;
double r68576 = r68572 / r68575;
return r68576;
}
double f(double x, double y) {
double r68577 = y;
double r68578 = -3.23505880669575e+153;
bool r68579 = r68577 <= r68578;
double r68580 = -1.0;
double r68581 = log1p(r68580);
double r68582 = expm1(r68581);
double r68583 = -7.331061585121293e-158;
bool r68584 = r68577 <= r68583;
double r68585 = x;
double r68586 = r68585 - r68577;
double r68587 = r68585 + r68577;
double r68588 = r68586 * r68587;
double r68589 = r68585 * r68585;
double r68590 = r68577 * r68577;
double r68591 = r68589 + r68590;
double r68592 = r68588 / r68591;
double r68593 = log1p(r68592);
double r68594 = expm1(r68593);
double r68595 = 1.3645633303893502e-189;
bool r68596 = r68577 <= r68595;
double r68597 = 1.0;
double r68598 = r68596 ? r68597 : r68594;
double r68599 = r68584 ? r68594 : r68598;
double r68600 = r68579 ? r68582 : r68599;
return r68600;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.5 |
|---|---|
| Target | 0.1 |
| Herbie | 5.3 |
if y < -3.23505880669575e+153Initial program 63.5
rmApplied expm1-log1p-u63.5
Taylor expanded around 0 0
if -3.23505880669575e+153 < y < -7.331061585121293e-158 or 1.3645633303893502e-189 < y Initial program 1.7
rmApplied expm1-log1p-u1.7
if -7.331061585121293e-158 < y < 1.3645633303893502e-189Initial program 30.4
Taylor expanded around inf 14.9
Final simplification5.3
herbie shell --seed 2020083 +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))))