\sqrt{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;x \leq -6.518081105388684 \cdot 10^{+114}:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq -4.142924173025851 \cdot 10^{-210}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{elif}\;x \leq 6.004365564520266 \cdot 10^{-207}:\\
\;\;\;\;y\\
\mathbf{elif}\;x \leq 42148.37987214342:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}(FPCore (x y) :precision binary64 (sqrt (+ (* x x) (* y y))))
(FPCore (x y)
:precision binary64
(if (<= x -6.518081105388684e+114)
(- x)
(if (<= x -4.142924173025851e-210)
(sqrt (+ (* x x) (* y y)))
(if (<= x 6.004365564520266e-207)
y
(if (<= x 42148.37987214342) (sqrt (+ (* x x) (* y y))) x)))))double code(double x, double y) {
return sqrt((x * x) + (y * y));
}
double code(double x, double y) {
double tmp;
if (x <= -6.518081105388684e+114) {
tmp = -x;
} else if (x <= -4.142924173025851e-210) {
tmp = sqrt((x * x) + (y * y));
} else if (x <= 6.004365564520266e-207) {
tmp = y;
} else if (x <= 42148.37987214342) {
tmp = sqrt((x * x) + (y * y));
} else {
tmp = x;
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.6 |
|---|---|
| Target | 17.7 |
| Herbie | 18.8 |
if x < -6.51808110538868361e114Initial program 53.7
Taylor expanded around -inf 10.5
Simplified10.5
if -6.51808110538868361e114 < x < -4.1429241730258509e-210 or 6.00436556452026608e-207 < x < 42148.3798721434214Initial program 18.8
if -4.1429241730258509e-210 < x < 6.00436556452026608e-207Initial program 30.0
Taylor expanded around 0 32.9
if 42148.3798721434214 < x Initial program 40.5
Taylor expanded around inf 14.7
Final simplification18.8
herbie shell --seed 2020231
(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))))