\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\begin{array}{l}
\mathbf{if}\;x \le -4.90401259865907417 \cdot 10^{153}:\\
\;\;\;\;-1 \cdot x\\
\mathbf{elif}\;x \le 7.4023060657315993 \cdot 10^{90}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}double code(double x, double y, double z) {
return sqrt((((x * x) + (y * y)) + (z * z)));
}
double code(double x, double y, double z) {
double temp;
if ((x <= -4.904012598659074e+153)) {
temp = (-1.0 * x);
} else {
double temp_1;
if ((x <= 7.402306065731599e+90)) {
temp_1 = sqrt((((x * x) + (y * y)) + (z * z)));
} else {
temp_1 = x;
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.1 |
|---|---|
| Target | 26.1 |
| Herbie | 25.4 |
if x < -4.904012598659074e+153Initial program 63.8
Taylor expanded around -inf 13.9
if -4.904012598659074e+153 < x < 7.402306065731599e+90Initial program 29.2
if 7.402306065731599e+90 < x Initial program 54.6
Taylor expanded around inf 18.9
Final simplification25.4
herbie shell --seed 2020058
(FPCore (x y z)
:name "FRP.Yampa.Vector3:vector3Rho from Yampa-0.10.2"
:precision binary64
:herbie-target
(if (< z -6.396479394109776e+136) (- z) (if (< z 7.320293694404182e+117) (sqrt (+ (+ (* z z) (* x x)) (* y y))) z))
(sqrt (+ (+ (* x x) (* y y)) (* z z))))