\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\begin{array}{l}
\mathbf{if}\;x \le -2.199349386776017456661293481624717960114 \cdot 10^{110}:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \le 3.408719160070714088752655754041470680881 \cdot 10^{143}:\\
\;\;\;\;\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 r42605385 = x;
double r42605386 = r42605385 * r42605385;
double r42605387 = y;
double r42605388 = r42605387 * r42605387;
double r42605389 = r42605386 + r42605388;
double r42605390 = z;
double r42605391 = r42605390 * r42605390;
double r42605392 = r42605389 + r42605391;
double r42605393 = sqrt(r42605392);
return r42605393;
}
double f(double x, double y, double z) {
double r42605394 = x;
double r42605395 = -2.1993493867760175e+110;
bool r42605396 = r42605394 <= r42605395;
double r42605397 = -r42605394;
double r42605398 = 3.408719160070714e+143;
bool r42605399 = r42605394 <= r42605398;
double r42605400 = r42605394 * r42605394;
double r42605401 = y;
double r42605402 = r42605401 * r42605401;
double r42605403 = r42605400 + r42605402;
double r42605404 = z;
double r42605405 = r42605404 * r42605404;
double r42605406 = r42605403 + r42605405;
double r42605407 = sqrt(r42605406);
double r42605408 = r42605399 ? r42605407 : r42605394;
double r42605409 = r42605396 ? r42605397 : r42605408;
return r42605409;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.2 |
|---|---|
| Target | 25.7 |
| Herbie | 25.7 |
if x < -2.1993493867760175e+110Initial program 56.6
Taylor expanded around -inf 19.1
Simplified19.1
if -2.1993493867760175e+110 < x < 3.408719160070714e+143Initial program 29.5
if 3.408719160070714e+143 < x Initial program 61.8
Taylor expanded around inf 14.1
Final simplification25.7
herbie shell --seed 2019174
(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))))