\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}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.91773166521773073 \cdot 10^{-160}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\mathbf{elif}\;y \le 2.87578004264953974 \cdot 10^{-160}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x + y \cdot y}{\left(x - y\right) \cdot \left(x + y\right)}}\\
\end{array}double f(double x, double y) {
double r101160 = x;
double r101161 = y;
double r101162 = r101160 - r101161;
double r101163 = r101160 + r101161;
double r101164 = r101162 * r101163;
double r101165 = r101160 * r101160;
double r101166 = r101161 * r101161;
double r101167 = r101165 + r101166;
double r101168 = r101164 / r101167;
return r101168;
}
double f(double x, double y) {
double r101169 = y;
double r101170 = -1.693074810444792e+150;
bool r101171 = r101169 <= r101170;
double r101172 = -1.0;
double r101173 = -1.9177316652177307e-160;
bool r101174 = r101169 <= r101173;
double r101175 = x;
double r101176 = r101175 - r101169;
double r101177 = r101175 + r101169;
double r101178 = r101176 * r101177;
double r101179 = r101175 * r101175;
double r101180 = r101169 * r101169;
double r101181 = r101179 + r101180;
double r101182 = r101178 / r101181;
double r101183 = 2.87578004264954e-160;
bool r101184 = r101169 <= r101183;
double r101185 = 1.0;
double r101186 = r101181 / r101178;
double r101187 = r101185 / r101186;
double r101188 = r101184 ? r101185 : r101187;
double r101189 = r101174 ? r101182 : r101188;
double r101190 = r101171 ? r101172 : r101189;
return r101190;
}




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
Taylor expanded around 0 0
if -1.693074810444792e+150 < y < -1.9177316652177307e-160Initial program 0.0
if -1.9177316652177307e-160 < y < 2.87578004264954e-160Initial program 30.6
Taylor expanded around inf 16.2
if 2.87578004264954e-160 < y Initial program 0.0
rmApplied clear-num0.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))))