\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.3369907459246656 \cdot 10^{+154}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.8149485600284774 \cdot 10^{-162}:\\
\;\;\;\;\log_* (1 + (e^{\frac{\left(x - y\right) \cdot \left(y + x\right)}{y \cdot y + x \cdot x}} - 1)^*)\\
\mathbf{elif}\;y \le 8.57058787857935 \cdot 10^{-162}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\log_* (1 + (e^{\frac{\left(x - y\right) \cdot \left(y + x\right)}{y \cdot y + x \cdot x}} - 1)^*)\\
\end{array}double f(double x, double y) {
double r33081182 = x;
double r33081183 = y;
double r33081184 = r33081182 - r33081183;
double r33081185 = r33081182 + r33081183;
double r33081186 = r33081184 * r33081185;
double r33081187 = r33081182 * r33081182;
double r33081188 = r33081183 * r33081183;
double r33081189 = r33081187 + r33081188;
double r33081190 = r33081186 / r33081189;
return r33081190;
}
double f(double x, double y) {
double r33081191 = y;
double r33081192 = -1.3369907459246656e+154;
bool r33081193 = r33081191 <= r33081192;
double r33081194 = -1.0;
double r33081195 = -1.8149485600284774e-162;
bool r33081196 = r33081191 <= r33081195;
double r33081197 = x;
double r33081198 = r33081197 - r33081191;
double r33081199 = r33081191 + r33081197;
double r33081200 = r33081198 * r33081199;
double r33081201 = r33081191 * r33081191;
double r33081202 = r33081197 * r33081197;
double r33081203 = r33081201 + r33081202;
double r33081204 = r33081200 / r33081203;
double r33081205 = expm1(r33081204);
double r33081206 = log1p(r33081205);
double r33081207 = 8.57058787857935e-162;
bool r33081208 = r33081191 <= r33081207;
double r33081209 = 1.0;
double r33081210 = r33081208 ? r33081209 : r33081206;
double r33081211 = r33081196 ? r33081206 : r33081210;
double r33081212 = r33081193 ? r33081194 : r33081211;
return r33081212;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.0 |
|---|---|
| Target | 0.0 |
| Herbie | 5.0 |
if y < -1.3369907459246656e+154Initial program 63.6
Taylor expanded around 0 0
if -1.3369907459246656e+154 < y < -1.8149485600284774e-162 or 8.57058787857935e-162 < y Initial program 0.0
rmApplied log1p-expm1-u0.0
if -1.8149485600284774e-162 < y < 8.57058787857935e-162Initial program 28.9
rmApplied log1p-expm1-u28.9
Taylor expanded around -inf 15.6
Final simplification5.0
herbie shell --seed 2019112 +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))))