\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\begin{array}{l}
\mathbf{if}\;x \le -2.114597052343943905521456364925785524812 \cdot 10^{96}:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \le 9.445373192608023995102518569819932542768 \cdot 10^{93}:\\
\;\;\;\;\sqrt{\left(y \cdot y + x \cdot x\right) + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}double f(double x, double y, double z) {
double r33477287 = x;
double r33477288 = r33477287 * r33477287;
double r33477289 = y;
double r33477290 = r33477289 * r33477289;
double r33477291 = r33477288 + r33477290;
double r33477292 = z;
double r33477293 = r33477292 * r33477292;
double r33477294 = r33477291 + r33477293;
double r33477295 = sqrt(r33477294);
return r33477295;
}
double f(double x, double y, double z) {
double r33477296 = x;
double r33477297 = -2.114597052343944e+96;
bool r33477298 = r33477296 <= r33477297;
double r33477299 = -r33477296;
double r33477300 = 9.445373192608024e+93;
bool r33477301 = r33477296 <= r33477300;
double r33477302 = y;
double r33477303 = r33477302 * r33477302;
double r33477304 = r33477296 * r33477296;
double r33477305 = r33477303 + r33477304;
double r33477306 = z;
double r33477307 = r33477306 * r33477306;
double r33477308 = r33477305 + r33477307;
double r33477309 = sqrt(r33477308);
double r33477310 = r33477301 ? r33477309 : r33477296;
double r33477311 = r33477298 ? r33477299 : r33477310;
return r33477311;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.7 |
|---|---|
| Target | 25.8 |
| Herbie | 25.3 |
if x < -2.114597052343944e+96Initial program 54.0
Taylor expanded around -inf 17.8
Simplified17.8
if -2.114597052343944e+96 < x < 9.445373192608024e+93Initial program 29.2
if 9.445373192608024e+93 < x Initial program 53.3
Taylor expanded around inf 18.3
Final simplification25.3
herbie shell --seed 2019200
(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))))