\sqrt{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;x \le -8.953163933293596454341424469878526728026 \cdot 10^{119}:\\
\;\;\;\;-1 \cdot x\\
\mathbf{elif}\;x \le 2.93160876788335701324895973715263720284 \cdot 10^{138}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}double f(double x, double y) {
double r548981 = x;
double r548982 = r548981 * r548981;
double r548983 = y;
double r548984 = r548983 * r548983;
double r548985 = r548982 + r548984;
double r548986 = sqrt(r548985);
return r548986;
}
double f(double x, double y) {
double r548987 = x;
double r548988 = -8.953163933293596e+119;
bool r548989 = r548987 <= r548988;
double r548990 = -1.0;
double r548991 = r548990 * r548987;
double r548992 = 2.931608767883357e+138;
bool r548993 = r548987 <= r548992;
double r548994 = r548987 * r548987;
double r548995 = y;
double r548996 = r548995 * r548995;
double r548997 = r548994 + r548996;
double r548998 = sqrt(r548997);
double r548999 = r548993 ? r548998 : r548987;
double r549000 = r548989 ? r548991 : r548999;
return r549000;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.2 |
|---|---|
| Target | 17.6 |
| Herbie | 17.5 |
if x < -8.953163933293596e+119Initial program 55.7
Taylor expanded around -inf 9.5
if -8.953163933293596e+119 < x < 2.931608767883357e+138Initial program 20.9
if 2.931608767883357e+138 < x Initial program 59.0
Taylor expanded around inf 8.0
Final simplification17.5
herbie shell --seed 2019303
(FPCore (x y)
:name "Data.Octree.Internal:octantDistance from Octree-0.5.4.2"
:precision binary64
:herbie-target
(if (< x -1.123695082659983e145) (- x) (if (< x 1.11655762118336204e93) (sqrt (+ (* x x) (* y y))) x))
(sqrt (+ (* x x) (* y y))))