\sqrt{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \leq 1.1776961076709698 \cdot 10^{-158}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq 9.723511542146676 \cdot 10^{+37}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{elif}\;y \leq 5.577535844625118 \cdot 10^{+41}:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}(FPCore (x y) :precision binary64 (sqrt (+ (* x x) (* y y))))
(FPCore (x y)
:precision binary64
(if (<= y 1.1776961076709698e-158)
(- x)
(if (<= y 9.723511542146676e+37)
(sqrt (+ (* x x) (* y y)))
(if (<= y 5.577535844625118e+41) (- x) y))))double code(double x, double y) {
return sqrt((x * x) + (y * y));
}
double code(double x, double y) {
double tmp;
if (y <= 1.1776961076709698e-158) {
tmp = -x;
} else if (y <= 9.723511542146676e+37) {
tmp = sqrt((x * x) + (y * y));
} else if (y <= 5.577535844625118e+41) {
tmp = -x;
} else {
tmp = y;
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.9 |
|---|---|
| Target | 17.3 |
| Herbie | 7.8 |
if y < 1.1776961076709698e-158 or 9.7235115421466756e37 < y < 5.57753584462511827e41Initial program 32.8
Taylor expanded around -inf 5.7
if 1.1776961076709698e-158 < y < 9.7235115421466756e37Initial program 11.3
if 5.57753584462511827e41 < y Initial program 42.8
Taylor expanded around 0 7.9
Final simplification7.8
herbie shell --seed 2021093
(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))))