\sqrt{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \leq 2.7251934092483667 \cdot 10^{-207}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq 9.39928376613555 \cdot 10^{-163}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 3.4872351096697653 \cdot 10^{+118}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}(FPCore (x y) :precision binary64 (sqrt (+ (* x x) (* y y))))
(FPCore (x y)
:precision binary64
(if (<= y 2.7251934092483667e-207)
(- x)
(if (<= y 9.39928376613555e-163)
y
(if (<= y 3.4872351096697653e+118) (sqrt (+ (* x x) (* y y))) y))))double code(double x, double y) {
return sqrt((x * x) + (y * y));
}
double code(double x, double y) {
double tmp;
if (y <= 2.7251934092483667e-207) {
tmp = -x;
} else if (y <= 9.39928376613555e-163) {
tmp = y;
} else if (y <= 3.4872351096697653e+118) {
tmp = sqrt((x * x) + (y * y));
} else {
tmp = y;
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 32.1 |
|---|---|
| Target | 17.9 |
| Herbie | 8.1 |
if y < 2.7251934092483667e-207Initial program 32.1
Taylor expanded around -inf 3.1
if 2.7251934092483667e-207 < y < 9.39928376613555e-163 or 3.4872351096697653e118 < y Initial program 52.5
Taylor expanded around 0 10.0
if 9.39928376613555e-163 < y < 3.4872351096697653e118Initial program 11.4
Final simplification8.1
herbie shell --seed 2021043
(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))))