\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -4.75850372698848152 \cdot 10^{153}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -2.3410769194630859 \cdot 10^{-140}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}}\\
\mathbf{elif}\;y \le 3.58789802840366625 \cdot 10^{-232}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \le 2.6348364519402426 \cdot 10^{-211}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le 1.29090338816018215 \cdot 10^{-163}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\right)}^{3}}\\
\end{array}double code(double x, double y) {
return ((double) (((double) (((double) (x - y)) * ((double) (x + y)))) / ((double) (((double) (x * x)) + ((double) (y * y))))));
}
double code(double x, double y) {
double VAR;
if ((y <= -4.7585037269884815e+153)) {
VAR = -1.0;
} else {
double VAR_1;
if ((y <= -2.341076919463086e-140)) {
VAR_1 = ((double) (((double) (((double) (x - y)) * ((double) (x + y)))) / ((double) (((double) sqrt(((double) (((double) (x * x)) + ((double) (y * y)))))) * ((double) sqrt(((double) (((double) (x * x)) + ((double) (y * y))))))))));
} else {
double VAR_2;
if ((y <= 3.587898028403666e-232)) {
VAR_2 = 1.0;
} else {
double VAR_3;
if ((y <= 2.6348364519402426e-211)) {
VAR_3 = -1.0;
} else {
double VAR_4;
if ((y <= 1.2909033881601822e-163)) {
VAR_4 = 1.0;
} else {
VAR_4 = ((double) cbrt(((double) pow(((double) (((double) (((double) (x - y)) * ((double) (x + y)))) / ((double) (((double) (x * x)) + ((double) (y * y)))))), 3.0))));
}
VAR_3 = VAR_4;
}
VAR_2 = VAR_3;
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.1 |
|---|---|
| Target | 0.1 |
| Herbie | 5.6 |
if y < -4.75850372698848152e153 or 3.58789802840366625e-232 < y < 2.6348364519402426e-211Initial program 60.5
Taylor expanded around 0 4.3
if -4.75850372698848152e153 < y < -2.3410769194630859e-140Initial program 0.0
rmApplied add-sqr-sqrt0.0
if -2.3410769194630859e-140 < y < 3.58789802840366625e-232 or 2.6348364519402426e-211 < y < 1.29090338816018215e-163Initial program 27.1
Taylor expanded around inf 15.2
if 1.29090338816018215e-163 < y Initial program 0.2
rmApplied add-cbrt-cube36.5
Applied add-cbrt-cube36.5
Applied add-cbrt-cube36.7
Applied cbrt-unprod36.0
Applied cbrt-undiv35.9
Simplified0.2
Final simplification5.6
herbie shell --seed 2020150
(FPCore (x y)
:name "Kahan p9 Example"
:precision binary64
:pre (and (< 0.0 x 1.0) (< y 1.0))
:herbie-target
(if (< 0.5 (fabs (/ x y)) 2.0) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1.0 (/ 2.0 (+ 1.0 (* (/ x y) (/ x y))))))
(/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))