\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\begin{array}{l}
\mathbf{if}\;x \le -18637040731758232623605069933264714596350:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \le 4.376373199179285827713056036389642308458 \cdot 10^{91}:\\
\;\;\;\;\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 r445650 = x;
double r445651 = r445650 * r445650;
double r445652 = y;
double r445653 = r445652 * r445652;
double r445654 = r445651 + r445653;
double r445655 = z;
double r445656 = r445655 * r445655;
double r445657 = r445654 + r445656;
double r445658 = sqrt(r445657);
return r445658;
}
double f(double x, double y, double z) {
double r445659 = x;
double r445660 = -1.8637040731758233e+40;
bool r445661 = r445659 <= r445660;
double r445662 = -r445659;
double r445663 = 4.376373199179286e+91;
bool r445664 = r445659 <= r445663;
double r445665 = r445659 * r445659;
double r445666 = y;
double r445667 = r445666 * r445666;
double r445668 = r445665 + r445667;
double r445669 = z;
double r445670 = r445669 * r445669;
double r445671 = r445668 + r445670;
double r445672 = sqrt(r445671);
double r445673 = r445664 ? r445672 : r445659;
double r445674 = r445661 ? r445662 : r445673;
return r445674;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.1 |
|---|---|
| Target | 25.4 |
| Herbie | 26.2 |
if x < -1.8637040731758233e+40Initial program 48.9
Taylor expanded around -inf 23.3
Simplified23.3
if -1.8637040731758233e+40 < x < 4.376373199179286e+91Initial program 29.6
if 4.376373199179286e+91 < x Initial program 53.4
Taylor expanded around inf 18.6
Final simplification26.2
herbie shell --seed 2019304
(FPCore (x y z)
:name "FRP.Yampa.Vector3:vector3Rho from Yampa-0.10.2"
:precision binary64
:herbie-target
(if (< z -6.3964793941097758e136) (- z) (if (< z 7.3202936944041821e117) (sqrt (+ (+ (* z z) (* x x)) (* y y))) z))
(sqrt (+ (+ (* x x) (* y y)) (* z z))))