\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\frac{\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\left|\sqrt[3]{3}\right|}}{\sqrt{\sqrt[3]{3}}}double code(double x, double y, double z) {
return ((double) sqrt(((double) (((double) (((double) (((double) (x * x)) + ((double) (y * y)))) + ((double) (z * z)))) / 3.0))));
}
double code(double x, double y, double z) {
return ((double) (((double) (((double) hypot(((double) hypot(x, y)), z)) / ((double) fabs(((double) cbrt(3.0)))))) / ((double) sqrt(((double) cbrt(3.0))))));
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.7 |
|---|---|
| Target | 25.3 |
| Herbie | 0.3 |
Initial program 37.7
rmApplied sqrt-div37.7
rmApplied add-sqr-sqrt37.7
Applied hypot-def28.4
rmApplied hypot-def0.4
rmApplied add-cube-cbrt0.4
Applied sqrt-prod0.4
Applied associate-/r*0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2020122 +o rules:numerics
(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)) (if (< z 7.320293694404182e+117) (/ (sqrt (+ (+ (* z z) (* x x)) (* y y))) (sqrt 3)) (* (sqrt 0.3333333333333333) z)))
(sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3)))