(FPCore (x y z) :precision binary64 (sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))
(FPCore (x y z) :precision binary64 (* (sqrt 0.3333333333333333) (hypot y (hypot x z))))
double code(double x, double y, double z) {
return sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
}
double code(double x, double y, double z) {
return sqrt(0.3333333333333333) * hypot(y, hypot(x, z));
}
public static double code(double x, double y, double z) {
return Math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
}
public static double code(double x, double y, double z) {
return Math.sqrt(0.3333333333333333) * Math.hypot(y, Math.hypot(x, z));
}
def code(x, y, z): return math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0))
def code(x, y, z): return math.sqrt(0.3333333333333333) * math.hypot(y, math.hypot(x, z))
function code(x, y, z) return sqrt(Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) + Float64(z * z)) / 3.0)) end
function code(x, y, z) return Float64(sqrt(0.3333333333333333) * hypot(y, hypot(x, z))) end
function tmp = code(x, y, z) tmp = sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0)); end
function tmp = code(x, y, z) tmp = sqrt(0.3333333333333333) * hypot(y, hypot(x, z)); end
code[x_, y_, z_] := N[Sqrt[N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := N[(N[Sqrt[0.3333333333333333], $MachinePrecision] * N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\sqrt{0.3333333333333333} \cdot \mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.0 |
|---|---|
| Target | 26.1 |
| Herbie | 0.4 |
Initial program 38.0
Simplified38.0
Applied egg-rr0.6
Applied egg-rr0.4
Final simplification0.4
herbie shell --seed 2022166
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.Pixel:doubleRmsOfRGB8 from repa-algorithms-3.4.0.1"
:precision binary64
:herbie-target
(if (< z -6.396479394109776e+136) (/ (- z) (sqrt 3.0)) (if (< z 7.320293694404182e+117) (/ (sqrt (+ (+ (* z z) (* x x)) (* y y))) (sqrt 3.0)) (* (sqrt 0.3333333333333333) z)))
(sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))