\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}
\begin{array}{l}
\mathbf{if}\;z \leq 4.403892363675905 \cdot 10^{-112}:\\
\;\;\;\;-0.5 \cdot \left(y \cdot \frac{y}{x} + \frac{z}{\frac{x}{z}}\right) - x\\
\mathbf{elif}\;z \leq 132.10635457596226:\\
\;\;\;\;\sqrt{{x}^{2} + z \cdot z}\\
\mathbf{elif}\;z \leq 2.392365744457182 \cdot 10^{+43}:\\
\;\;\;\;-0.5 \cdot \left(\frac{y}{\frac{x}{y}} + \frac{z \cdot z}{x}\right) - x\\
\mathbf{elif}\;z \leq 4.6936553999927715 \cdot 10^{+146}:\\
\;\;\;\;\sqrt{z \cdot z + \left(x \cdot x + y \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
(FPCore (x y z) :precision binary64 (sqrt (+ (+ (* x x) (* y y)) (* z z))))
(FPCore (x y z)
:precision binary64
(if (<= z 4.403892363675905e-112)
(- (* -0.5 (+ (* y (/ y x)) (/ z (/ x z)))) x)
(if (<= z 132.10635457596226)
(sqrt (+ (pow x 2.0) (* z z)))
(if (<= z 2.392365744457182e+43)
(- (* -0.5 (+ (/ y (/ x y)) (/ (* z z) x))) x)
(if (<= z 4.6936553999927715e+146)
(sqrt (+ (* z z) (+ (* x x) (* y y))))
z)))))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 tmp;
if (z <= 4.403892363675905e-112) {
tmp = (-0.5 * ((y * (y / x)) + (z / (x / z)))) - x;
} else if (z <= 132.10635457596226) {
tmp = sqrt(pow(x, 2.0) + (z * z));
} else if (z <= 2.392365744457182e+43) {
tmp = (-0.5 * ((y / (x / y)) + ((z * z) / x))) - x;
} else if (z <= 4.6936553999927715e+146) {
tmp = sqrt((z * z) + ((x * x) + (y * y)));
} else {
tmp = z;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.0 |
|---|---|
| Target | 18.8 |
| Herbie | 10.8 |
if z < 4.40389236367590516e-112Initial program 31.8
Taylor expanded around -inf 9.1
Simplified9.1
rmApplied *-un-lft-identity_binary649.1
Applied times-frac_binary644.0
Simplified4.0
rmApplied associate-/l*_binary643.7
if 4.40389236367590516e-112 < z < 132.10635457596226Initial program 19.6
Taylor expanded around inf 20.0
if 132.10635457596226 < z < 2.39236574445718203e43Initial program 21.5
Taylor expanded around -inf 28.5
Simplified28.5
rmApplied associate-/l*_binary6426.7
if 2.39236574445718203e43 < z < 4.693655399992771e146Initial program 17.0
if 4.693655399992771e146 < z Initial program 62.2
Taylor expanded around inf 7.8
Final simplification10.8
herbie shell --seed 2021190
(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))))