\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.64081725270371729 \cdot 10^{149}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.75047117514697987 \cdot 10^{-136}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\mathbf{elif}\;y \le 1.7784148690303961 \cdot 10^{-177}:\\
\;\;\;\;\frac{x - y}{x - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\end{array}double f(double x, double y) {
double r71159 = x;
double r71160 = y;
double r71161 = r71159 - r71160;
double r71162 = r71159 + r71160;
double r71163 = r71161 * r71162;
double r71164 = r71159 * r71159;
double r71165 = r71160 * r71160;
double r71166 = r71164 + r71165;
double r71167 = r71163 / r71166;
return r71167;
}
double f(double x, double y) {
double r71168 = y;
double r71169 = -1.6408172527037173e+149;
bool r71170 = r71168 <= r71169;
double r71171 = -1.0;
double r71172 = -1.75047117514698e-136;
bool r71173 = r71168 <= r71172;
double r71174 = x;
double r71175 = r71174 - r71168;
double r71176 = r71174 + r71168;
double r71177 = r71175 * r71176;
double r71178 = r71174 * r71174;
double r71179 = r71168 * r71168;
double r71180 = r71178 + r71179;
double r71181 = r71177 / r71180;
double r71182 = 1.7784148690303961e-177;
bool r71183 = r71168 <= r71182;
double r71184 = r71175 / r71175;
double r71185 = r71183 ? r71184 : r71181;
double r71186 = r71173 ? r71181 : r71185;
double r71187 = r71170 ? r71171 : r71186;
return r71187;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.5 |
|---|---|
| Target | 0.1 |
| Herbie | 6.1 |
if y < -1.6408172527037173e+149Initial program 62.2
Taylor expanded around 0 0
if -1.6408172527037173e+149 < y < -1.75047117514698e-136 or 1.7784148690303961e-177 < y Initial program 1.1
if -1.75047117514698e-136 < y < 1.7784148690303961e-177Initial program 28.0
rmApplied associate-/l*28.9
Taylor expanded around inf 16.6
Final simplification6.1
herbie shell --seed 2020059
(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))))