\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\begin{array}{l}
\mathbf{if}\;x \le -3.7872604668456225 \cdot 10^{151}:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \le 2.36744042376759273 \cdot 10^{134}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}double f(double x, double y, double z) {
double r519020 = x;
double r519021 = r519020 * r519020;
double r519022 = y;
double r519023 = r519022 * r519022;
double r519024 = r519021 + r519023;
double r519025 = z;
double r519026 = r519025 * r519025;
double r519027 = r519024 + r519026;
double r519028 = sqrt(r519027);
return r519028;
}
double f(double x, double y, double z) {
double r519029 = x;
double r519030 = -3.7872604668456225e+151;
bool r519031 = r519029 <= r519030;
double r519032 = -r519029;
double r519033 = 2.3674404237675927e+134;
bool r519034 = r519029 <= r519033;
double r519035 = r519029 * r519029;
double r519036 = y;
double r519037 = r519036 * r519036;
double r519038 = r519035 + r519037;
double r519039 = z;
double r519040 = r519039 * r519039;
double r519041 = r519038 + r519040;
double r519042 = sqrt(r519041);
double r519043 = r519034 ? r519042 : r519029;
double r519044 = r519031 ? r519032 : r519043;
return r519044;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.8 |
|---|---|
| Target | 25.0 |
| Herbie | 25.7 |
if x < -3.7872604668456225e+151Initial program 63.2
Taylor expanded around -inf 14.4
Simplified14.4
if -3.7872604668456225e+151 < x < 2.3674404237675927e+134Initial program 29.4
if 2.3674404237675927e+134 < x Initial program 59.7
Taylor expanded around inf 17.0
Final simplification25.7
herbie shell --seed 2019198
(FPCore (x y z)
:name "FRP.Yampa.Vector3:vector3Rho from Yampa-0.10.2"
: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))))