\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -9.821782313314639955086003839853747327964 \cdot 10^{153}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.937646393364570937539099703487067921288 \cdot 10^{-161}:\\
\;\;\;\;\frac{\frac{x \cdot x - y \cdot y}{\frac{x \cdot x + y \cdot y}{\left(x - y\right) \cdot \left(x + y\right)}}}{\left(x + y\right) \cdot \left(x - y\right)}\\
\mathbf{elif}\;y \le 1.828260016637030233456157191815862132037 \cdot 10^{-162}:\\
\;\;\;\;1\\
\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 r60254 = x;
double r60255 = y;
double r60256 = r60254 - r60255;
double r60257 = r60254 + r60255;
double r60258 = r60256 * r60257;
double r60259 = r60254 * r60254;
double r60260 = r60255 * r60255;
double r60261 = r60259 + r60260;
double r60262 = r60258 / r60261;
return r60262;
}
double f(double x, double y) {
double r60263 = y;
double r60264 = -9.82178231331464e+153;
bool r60265 = r60263 <= r60264;
double r60266 = -1.0;
double r60267 = -1.937646393364571e-161;
bool r60268 = r60263 <= r60267;
double r60269 = x;
double r60270 = r60269 * r60269;
double r60271 = r60263 * r60263;
double r60272 = r60270 - r60271;
double r60273 = r60270 + r60271;
double r60274 = r60269 - r60263;
double r60275 = r60269 + r60263;
double r60276 = r60274 * r60275;
double r60277 = r60273 / r60276;
double r60278 = r60272 / r60277;
double r60279 = r60275 * r60274;
double r60280 = r60278 / r60279;
double r60281 = 1.8282600166370302e-162;
bool r60282 = r60263 <= r60281;
double r60283 = 1.0;
double r60284 = r60276 / r60273;
double r60285 = r60282 ? r60283 : r60284;
double r60286 = r60268 ? r60280 : r60285;
double r60287 = r60265 ? r60266 : r60286;
return r60287;
}




Bits error versus x




Bits error versus y
Results
| Original | 19.9 |
|---|---|
| Target | 0.1 |
| Herbie | 4.6 |
if y < -9.82178231331464e+153Initial program 63.9
rmApplied clear-num63.9
rmApplied flip-+63.9
Applied flip--63.9
Applied frac-times64.0
Applied associate-/r/64.0
Applied associate-/r*64.0
Simplified63.9
Taylor expanded around 0 0
if -9.82178231331464e+153 < y < -1.937646393364571e-161Initial program 0.0
rmApplied clear-num0.0
rmApplied flip-+0.0
Applied flip--0.1
Applied frac-times27.9
Applied associate-/r/28.0
Applied associate-/r*28.0
Simplified0.0
if -1.937646393364571e-161 < y < 1.8282600166370302e-162Initial program 29.7
rmApplied clear-num29.7
Taylor expanded around inf 14.6
if 1.8282600166370302e-162 < y Initial program 0.1
Final simplification4.6
herbie shell --seed 2019303
(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))))