\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -3.847434879443193393633321330852372755378 \cdot 10^{151}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.694063246808970668811003130641552295003 \cdot 10^{-162}:\\
\;\;\;\;e^{\mathsf{log1p}\left(\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\right)} - 1\\
\mathbf{elif}\;y \le 6.451959238219760281097758056287369172736 \cdot 10^{-208}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \le 1.336866892806927934140174920733392856435 \cdot 10^{-166}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;e^{\mathsf{log1p}\left(\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\right)} - 1\\
\end{array}double f(double x, double y) {
double r90644 = x;
double r90645 = y;
double r90646 = r90644 - r90645;
double r90647 = r90644 + r90645;
double r90648 = r90646 * r90647;
double r90649 = r90644 * r90644;
double r90650 = r90645 * r90645;
double r90651 = r90649 + r90650;
double r90652 = r90648 / r90651;
return r90652;
}
double f(double x, double y) {
double r90653 = y;
double r90654 = -3.8474348794431934e+151;
bool r90655 = r90653 <= r90654;
double r90656 = -1.0;
double r90657 = -1.6940632468089707e-162;
bool r90658 = r90653 <= r90657;
double r90659 = x;
double r90660 = r90659 - r90653;
double r90661 = r90659 + r90653;
double r90662 = r90660 * r90661;
double r90663 = r90659 * r90659;
double r90664 = r90653 * r90653;
double r90665 = r90663 + r90664;
double r90666 = r90662 / r90665;
double r90667 = log1p(r90666);
double r90668 = exp(r90667);
double r90669 = 1.0;
double r90670 = r90668 - r90669;
double r90671 = 6.45195923821976e-208;
bool r90672 = r90653 <= r90671;
double r90673 = 1.336866892806928e-166;
bool r90674 = r90653 <= r90673;
double r90675 = r90674 ? r90656 : r90670;
double r90676 = r90672 ? r90669 : r90675;
double r90677 = r90658 ? r90670 : r90676;
double r90678 = r90655 ? r90656 : r90677;
return r90678;
}




Bits error versus x




Bits error versus y
Results
| Original | 19.6 |
|---|---|
| Target | 0.0 |
| Herbie | 5.5 |
if y < -3.8474348794431934e+151 or 6.45195923821976e-208 < y < 1.336866892806928e-166Initial program 55.7
Taylor expanded around 0 8.5
if -3.8474348794431934e+151 < y < -1.6940632468089707e-162 or 1.336866892806928e-166 < y Initial program 0.3
rmApplied log1p-expm1-u0.3
rmApplied expm1-log1p-u0.3
Simplified0.3
rmApplied expm1-udef0.3
if -1.6940632468089707e-162 < y < 6.45195923821976e-208Initial program 28.7
Taylor expanded around inf 13.4
Final simplification5.5
herbie shell --seed 2019353 +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))))