\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.3730354842790037 \cdot 10^{+154}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -4.534922755068586 \cdot 10^{-162}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(y + x\right)}{y \cdot y + x \cdot x}\\
\mathbf{elif}\;y \le 3.053717103568057 \cdot 10^{-167}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(y + x\right)}{y \cdot y + x \cdot x}\\
\end{array}double f(double x, double y) {
double r25378231 = x;
double r25378232 = y;
double r25378233 = r25378231 - r25378232;
double r25378234 = r25378231 + r25378232;
double r25378235 = r25378233 * r25378234;
double r25378236 = r25378231 * r25378231;
double r25378237 = r25378232 * r25378232;
double r25378238 = r25378236 + r25378237;
double r25378239 = r25378235 / r25378238;
return r25378239;
}
double f(double x, double y) {
double r25378240 = y;
double r25378241 = -1.3730354842790037e+154;
bool r25378242 = r25378240 <= r25378241;
double r25378243 = -1.0;
double r25378244 = -4.534922755068586e-162;
bool r25378245 = r25378240 <= r25378244;
double r25378246 = x;
double r25378247 = r25378246 - r25378240;
double r25378248 = r25378240 + r25378246;
double r25378249 = r25378247 * r25378248;
double r25378250 = r25378240 * r25378240;
double r25378251 = r25378246 * r25378246;
double r25378252 = r25378250 + r25378251;
double r25378253 = r25378249 / r25378252;
double r25378254 = 3.053717103568057e-167;
bool r25378255 = r25378240 <= r25378254;
double r25378256 = 1.0;
double r25378257 = r25378255 ? r25378256 : r25378253;
double r25378258 = r25378245 ? r25378253 : r25378257;
double r25378259 = r25378242 ? r25378243 : r25378258;
return r25378259;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.1 |
|---|---|
| Target | 0.1 |
| Herbie | 5.2 |
if y < -1.3730354842790037e+154Initial program 63.6
Taylor expanded around 0 0
if -1.3730354842790037e+154 < y < -4.534922755068586e-162 or 3.053717103568057e-167 < y Initial program 0.5
if -4.534922755068586e-162 < y < 3.053717103568057e-167Initial program 29.6
rmApplied associate-/l*29.9
rmApplied *-un-lft-identity29.9
Applied add-sqr-sqrt29.9
Applied times-frac29.8
Applied *-un-lft-identity29.8
Applied *-un-lft-identity29.8
Applied distribute-lft-out--29.8
Applied times-frac29.9
Simplified29.9
Taylor expanded around -inf 15.7
Final simplification5.2
herbie shell --seed 2019107
(FPCore (x y)
:name "Kahan p9 Example"
:pre (and (< 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))))