(FPCore (x y z) :precision binary64 (sqrt (+ (+ (* x x) (* y y)) (* z z))))
(FPCore (x y z) :precision binary64 (hypot x (hypot 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) {
return hypot(x, hypot(y, z));
}
public static double code(double x, double y, double z) {
return Math.sqrt((((x * x) + (y * y)) + (z * z)));
}
public static double code(double x, double y, double z) {
return Math.hypot(x, Math.hypot(y, z));
}
def code(x, y, z): return math.sqrt((((x * x) + (y * y)) + (z * z)))
def code(x, y, z): return math.hypot(x, math.hypot(y, z))
function code(x, y, z) return sqrt(Float64(Float64(Float64(x * x) + Float64(y * y)) + Float64(z * z))) end
function code(x, y, z) return hypot(x, hypot(y, z)) end
function tmp = code(x, y, z) tmp = sqrt((((x * x) + (y * y)) + (z * z))); end
function tmp = code(x, y, z) tmp = hypot(x, hypot(y, z)); end
code[x_, y_, z_] := N[Sqrt[N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := N[Sqrt[x ^ 2 + N[Sqrt[y ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]
\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}
\mathsf{hypot}\left(x, \mathsf{hypot}\left(y, z\right)\right)




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.5 |
|---|---|
| Target | 24.9 |
| Herbie | 0.0 |
Initial program 37.5
Applied egg-rr0.0
Final simplification0.0
herbie shell --seed 2022160
(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))))