\sqrt{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;x \leq -7.520886186082616 \cdot 10^{+119}:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq -5.274722593747874 \cdot 10^{-207}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{elif}\;x \leq 1.259166188322571 \cdot 10^{-253}:\\
\;\;\;\;y\\
\mathbf{elif}\;x \leq 1.5992908826155528 \cdot 10^{+115}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}double code(double x, double y) {
return ((double) sqrt(((double) (((double) (x * x)) + ((double) (y * y))))));
}
double code(double x, double y) {
double VAR;
if ((x <= -7.520886186082616e+119)) {
VAR = ((double) -(x));
} else {
double VAR_1;
if ((x <= -5.274722593747874e-207)) {
VAR_1 = ((double) sqrt(((double) (((double) (x * x)) + ((double) (y * y))))));
} else {
double VAR_2;
if ((x <= 1.259166188322571e-253)) {
VAR_2 = y;
} else {
double VAR_3;
if ((x <= 1.5992908826155528e+115)) {
VAR_3 = ((double) sqrt(((double) (((double) (x * x)) + ((double) (y * y))))));
} else {
VAR_3 = x;
}
VAR_2 = VAR_3;
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.2 |
|---|---|
| Target | 17.5 |
| Herbie | 18.0 |
if x < -7.5208861860826161e119Initial program Error: 54.0 bits
Taylor expanded around -inf Error: 8.9 bits
SimplifiedError: 8.9 bits
if -7.5208861860826161e119 < x < -5.27472259374787428e-207 or 1.25916618832257105e-253 < x < 1.59929088261555279e115Initial program Error: 19.4 bits
if -5.27472259374787428e-207 < x < 1.25916618832257105e-253Initial program Error: 29.8 bits
Taylor expanded around 0 Error: 33.6 bits
if 1.59929088261555279e115 < x Initial program Error: 53.9 bits
Taylor expanded around inf Error: 9.1 bits
Final simplificationError: 18.0 bits
herbie shell --seed 2020200
(FPCore (x y)
:name "Data.Octree.Internal:octantDistance from Octree-0.5.4.2"
:precision binary64
:herbie-target
(if (< x -1.1236950826599826e+145) (- x) (if (< x 1.116557621183362e+93) (sqrt (+ (* x x) (* y y))) x))
(sqrt (+ (* x x) (* y y))))