\sqrt{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;x \le -9.97733214615282287 \cdot 10^{89}:\\
\;\;\;\;-1 \cdot x\\
\mathbf{elif}\;x \le -2.6982430225033068 \cdot 10^{-174}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{elif}\;x \le 3.7706602894998885 \cdot 10^{-238}:\\
\;\;\;\;y\\
\mathbf{elif}\;x \le 1.6531905343411006 \cdot 10^{78}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}double code(double x, double y) {
return sqrt(((x * x) + (y * y)));
}
double code(double x, double y) {
double temp;
if ((x <= -9.977332146152823e+89)) {
temp = (-1.0 * x);
} else {
double temp_1;
if ((x <= -2.6982430225033068e-174)) {
temp_1 = sqrt(((x * x) + (y * y)));
} else {
double temp_2;
if ((x <= 3.7706602894998885e-238)) {
temp_2 = y;
} else {
double temp_3;
if ((x <= 1.6531905343411006e+78)) {
temp_3 = sqrt(((x * x) + (y * y)));
} else {
temp_3 = x;
}
temp_2 = temp_3;
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.5 |
|---|---|
| Target | 18.1 |
| Herbie | 18.5 |
if x < -9.977332146152823e+89Initial program 49.1
Taylor expanded around -inf 12.5
if -9.977332146152823e+89 < x < -2.6982430225033068e-174 or 3.7706602894998885e-238 < x < 1.6531905343411006e+78Initial program 18.3
if -2.6982430225033068e-174 < x < 3.7706602894998885e-238Initial program 32.0
Taylor expanded around 0 33.5
if 1.6531905343411006e+78 < x Initial program 48.4
Taylor expanded around inf 11.7
Final simplification18.5
herbie shell --seed 2020053
(FPCore (x y)
:name "Data.Octree.Internal:octantDistance from Octree-0.5.4.2"
:precision binary64
:herbie-target
(if (< x -1.123695082659983e+145) (- x) (if (< x 1.116557621183362e+93) (sqrt (+ (* x x) (* y y))) x))
(sqrt (+ (* x x) (* y y))))