\sqrt{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;x \le -2.77502973126125612 \cdot 10^{119}:\\
\;\;\;\;-1 \cdot x\\
\mathbf{elif}\;x \le 7.57619582189923613 \cdot 10^{130}:\\
\;\;\;\;\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 VAR;
if ((x <= -2.775029731261256e+119)) {
VAR = (-1.0 * x);
} else {
double VAR_1;
if ((x <= 7.576195821899236e+130)) {
VAR_1 = sqrt(((x * x) + (y * y)));
} else {
VAR_1 = x;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.4 |
|---|---|
| Target | 17.2 |
| Herbie | 17.1 |
if x < -2.775029731261256e+119Initial program 55.4
Taylor expanded around -inf 9.0
if -2.775029731261256e+119 < x < 7.576195821899236e+130Initial program 20.4
if 7.576195821899236e+130 < x Initial program 57.8
Taylor expanded around inf 9.9
Final simplification17.1
herbie shell --seed 2020091
(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))))