\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -7.49710851278169964 \cdot 10^{153}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -5.2769323245908286 \cdot 10^{-158}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\mathbf{elif}\;y \le 1.03984000614779373 \cdot 10^{-165}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\end{array}double code(double x, double y) {
return (((x - y) * (x + y)) / ((x * x) + (y * y)));
}
double code(double x, double y) {
double temp;
if ((y <= -7.4971085127817e+153)) {
temp = -1.0;
} else {
double temp_1;
if ((y <= -5.2769323245908286e-158)) {
temp_1 = (((x - y) * (x + y)) / ((x * x) + (y * y)));
} else {
double temp_2;
if ((y <= 1.0398400061477937e-165)) {
temp_2 = 1.0;
} else {
temp_2 = (((x - y) * (x + y)) / ((x * x) + (y * y)));
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.0 |
|---|---|
| Target | 0.0 |
| Herbie | 5.3 |
if y < -7.4971085127817e+153Initial program 63.9
Taylor expanded around 0 0
if -7.4971085127817e+153 < y < -5.2769323245908286e-158 or 1.0398400061477937e-165 < y Initial program 0.3
if -5.2769323245908286e-158 < y < 1.0398400061477937e-165Initial program 29.7
Taylor expanded around inf 16.3
Final simplification5.3
herbie shell --seed 2020053
(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))))