\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.6930748104447922 \cdot 10^{150}:\\
\;\;\;\;\frac{1}{-1}\\
\mathbf{elif}\;y \le -1.91773166521773073 \cdot 10^{-160}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}}\\
\mathbf{elif}\;y \le 2.87578004264953974 \cdot 10^{-160}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{{y}^{2} + {x}^{2}}{\left(x - y\right) \cdot \left(x + y\right)}}\\
\end{array}double f(double x, double y) {
double r89358 = x;
double r89359 = y;
double r89360 = r89358 - r89359;
double r89361 = r89358 + r89359;
double r89362 = r89360 * r89361;
double r89363 = r89358 * r89358;
double r89364 = r89359 * r89359;
double r89365 = r89363 + r89364;
double r89366 = r89362 / r89365;
return r89366;
}
double f(double x, double y) {
double r89367 = y;
double r89368 = -1.693074810444792e+150;
bool r89369 = r89367 <= r89368;
double r89370 = 1.0;
double r89371 = -1.0;
double r89372 = r89370 / r89371;
double r89373 = -1.9177316652177307e-160;
bool r89374 = r89367 <= r89373;
double r89375 = x;
double r89376 = r89375 - r89367;
double r89377 = r89375 + r89367;
double r89378 = r89376 * r89377;
double r89379 = r89375 * r89375;
double r89380 = r89367 * r89367;
double r89381 = r89379 + r89380;
double r89382 = sqrt(r89381);
double r89383 = r89382 * r89382;
double r89384 = r89378 / r89383;
double r89385 = 2.87578004264954e-160;
bool r89386 = r89367 <= r89385;
double r89387 = 2.0;
double r89388 = pow(r89367, r89387);
double r89389 = pow(r89375, r89387);
double r89390 = r89388 + r89389;
double r89391 = r89390 / r89378;
double r89392 = r89370 / r89391;
double r89393 = r89386 ? r89370 : r89392;
double r89394 = r89374 ? r89384 : r89393;
double r89395 = r89369 ? r89372 : r89394;
return r89395;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.6 |
|---|---|
| Target | 0.1 |
| Herbie | 5.2 |
if y < -1.693074810444792e+150Initial program 62.1
rmApplied add-sqr-sqrt62.1
rmApplied clear-num62.1
Simplified62.1
Taylor expanded around inf 0
if -1.693074810444792e+150 < y < -1.9177316652177307e-160Initial program 0.0
rmApplied add-sqr-sqrt0.0
if -1.9177316652177307e-160 < y < 2.87578004264954e-160Initial program 30.6
rmApplied add-sqr-sqrt30.6
rmApplied clear-num30.6
Simplified30.6
Taylor expanded around 0 16.2
if 2.87578004264954e-160 < y Initial program 0.0
rmApplied add-sqr-sqrt0.1
rmApplied clear-num0.1
Simplified0.1
Final simplification5.2
herbie shell --seed 2020042
(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))))