\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -9.553125844209864019349205574997414631362 \cdot 10^{153}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -2.262962472101785089653746326381466961868 \cdot 10^{-159}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y + x \cdot x} - \frac{y \cdot y}{y \cdot y + x \cdot x}\\
\mathbf{elif}\;y \le 4.982414937133197896822437436552107699435 \cdot 10^{-223}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \le 4.744541337219421296708284469703238777066 \cdot 10^{-178}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y + x \cdot x} - \frac{y \cdot y}{y \cdot y + x \cdot x}\\
\end{array}double f(double x, double y) {
double r4280385 = x;
double r4280386 = y;
double r4280387 = r4280385 - r4280386;
double r4280388 = r4280385 + r4280386;
double r4280389 = r4280387 * r4280388;
double r4280390 = r4280385 * r4280385;
double r4280391 = r4280386 * r4280386;
double r4280392 = r4280390 + r4280391;
double r4280393 = r4280389 / r4280392;
return r4280393;
}
double f(double x, double y) {
double r4280394 = y;
double r4280395 = -9.553125844209864e+153;
bool r4280396 = r4280394 <= r4280395;
double r4280397 = -1.0;
double r4280398 = -2.262962472101785e-159;
bool r4280399 = r4280394 <= r4280398;
double r4280400 = x;
double r4280401 = r4280400 * r4280400;
double r4280402 = r4280394 * r4280394;
double r4280403 = r4280402 + r4280401;
double r4280404 = r4280401 / r4280403;
double r4280405 = r4280402 / r4280403;
double r4280406 = r4280404 - r4280405;
double r4280407 = 4.982414937133198e-223;
bool r4280408 = r4280394 <= r4280407;
double r4280409 = 1.0;
double r4280410 = 4.7445413372194213e-178;
bool r4280411 = r4280394 <= r4280410;
double r4280412 = r4280411 ? r4280397 : r4280406;
double r4280413 = r4280408 ? r4280409 : r4280412;
double r4280414 = r4280399 ? r4280406 : r4280413;
double r4280415 = r4280396 ? r4280397 : r4280414;
return r4280415;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.6 |
|---|---|
| Target | 0.1 |
| Herbie | 5.9 |
if y < -9.553125844209864e+153 or 4.982414937133198e-223 < y < 4.7445413372194213e-178Initial program 57.1
Simplified57.1
Taylor expanded around 0 8.7
if -9.553125844209864e+153 < y < -2.262962472101785e-159 or 4.7445413372194213e-178 < y Initial program 1.0
Simplified1.0
if -2.262962472101785e-159 < y < 4.982414937133198e-223Initial program 30.1
Simplified30.1
Taylor expanded around inf 13.7
Final simplification5.9
herbie shell --seed 2019200
(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))))