\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\left|\frac{\mathsf{hypot}\left(1 \cdot \mathsf{hypot}\left(x, y\right), z\right)}{\sqrt{3}}\right|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 fabs((hypot((1.0 * hypot(x, y)), z) / sqrt(3.0)));
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.5 |
|---|---|
| Target | 25.6 |
| Herbie | 0.4 |
Initial program 37.5
rmApplied add-sqr-sqrt37.6
Applied add-sqr-sqrt37.6
Applied times-frac37.6
Applied rem-sqrt-square37.6
rmApplied add-sqr-sqrt37.6
Applied hypot-def28.6
rmApplied *-un-lft-identity28.6
Applied sqrt-prod28.6
Simplified28.6
Simplified0.4
Final simplification0.4
herbie shell --seed 2020056 +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)))