\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right) \cdot \sqrt{\frac{1}{3}}double f(double x, double y, double z) {
double r900933 = x;
double r900934 = r900933 * r900933;
double r900935 = y;
double r900936 = r900935 * r900935;
double r900937 = r900934 + r900936;
double r900938 = z;
double r900939 = r900938 * r900938;
double r900940 = r900937 + r900939;
double r900941 = 3.0;
double r900942 = r900940 / r900941;
double r900943 = sqrt(r900942);
return r900943;
}
double f(double x, double y, double z) {
double r900944 = x;
double r900945 = y;
double r900946 = hypot(r900944, r900945);
double r900947 = z;
double r900948 = hypot(r900946, r900947);
double r900949 = 1.0;
double r900950 = 3.0;
double r900951 = r900949 / r900950;
double r900952 = sqrt(r900951);
double r900953 = r900948 * r900952;
return r900953;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.9 |
|---|---|
| Target | 25.9 |
| Herbie | 0.4 |
Initial program 37.9
rmApplied div-inv37.9
Applied sqrt-prod38.0
rmApplied add-sqr-sqrt38.0
Applied hypot-def28.8
rmApplied hypot-def0.4
Final simplification0.4
herbie shell --seed 2020065 +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)))