\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -106.3060688461918488201263244263827800751:\\
\;\;\;\;\log \left(e^{-1}\right)\\
\mathbf{elif}\;y \le -1.112954613077047722664131657642916967389 \cdot 10^{-151}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + {y}^{2}}\\
\mathbf{elif}\;y \le 7.168109854324841883368591954908086893719 \cdot 10^{-160}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + {y}^{2}}}\right)\\
\end{array}double f(double x, double y) {
double r75276 = x;
double r75277 = y;
double r75278 = r75276 - r75277;
double r75279 = r75276 + r75277;
double r75280 = r75278 * r75279;
double r75281 = r75276 * r75276;
double r75282 = r75277 * r75277;
double r75283 = r75281 + r75282;
double r75284 = r75280 / r75283;
return r75284;
}
double f(double x, double y) {
double r75285 = y;
double r75286 = -106.30606884619185;
bool r75287 = r75285 <= r75286;
double r75288 = -1.0;
double r75289 = exp(r75288);
double r75290 = log(r75289);
double r75291 = -1.1129546130770477e-151;
bool r75292 = r75285 <= r75291;
double r75293 = x;
double r75294 = r75293 - r75285;
double r75295 = r75293 + r75285;
double r75296 = r75294 * r75295;
double r75297 = r75293 * r75293;
double r75298 = 2.0;
double r75299 = pow(r75285, r75298);
double r75300 = r75297 + r75299;
double r75301 = r75296 / r75300;
double r75302 = 7.168109854324842e-160;
bool r75303 = r75285 <= r75302;
double r75304 = 1.0;
double r75305 = exp(r75301);
double r75306 = log(r75305);
double r75307 = r75303 ? r75304 : r75306;
double r75308 = r75292 ? r75301 : r75307;
double r75309 = r75287 ? r75290 : r75308;
return r75309;
}




Bits error versus x




Bits error versus y
Results
| Original | 19.9 |
|---|---|
| Target | 0.1 |
| Herbie | 5.2 |
if y < -106.30606884619185Initial program 31.8
Taylor expanded around 0 31.8
Simplified31.8
rmApplied add-log-exp31.8
Taylor expanded around 0 0
if -106.30606884619185 < y < -1.1129546130770477e-151Initial program 0.0
Taylor expanded around 0 0.0
Simplified0.0
if -1.1129546130770477e-151 < y < 7.168109854324842e-160Initial program 28.5
Taylor expanded around 0 28.5
Simplified28.5
rmApplied add-log-exp28.5
Taylor expanded around inf 15.7
if 7.168109854324842e-160 < y Initial program 0.0
Taylor expanded around 0 0.0
Simplified0.0
rmApplied add-log-exp0.0
Final simplification5.2
herbie shell --seed 2019323
(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))))