\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 r965956 = x;
double r965957 = r965956 * r965956;
double r965958 = y;
double r965959 = r965958 * r965958;
double r965960 = r965957 + r965959;
double r965961 = z;
double r965962 = r965961 * r965961;
double r965963 = r965960 + r965962;
double r965964 = 3.0;
double r965965 = r965963 / r965964;
double r965966 = sqrt(r965965);
return r965966;
}
double f(double x, double y, double z) {
double r965967 = x;
double r965968 = y;
double r965969 = hypot(r965967, r965968);
double r965970 = z;
double r965971 = hypot(r965969, r965970);
double r965972 = 1.0;
double r965973 = 3.0;
double r965974 = r965972 / r965973;
double r965975 = sqrt(r965974);
double r965976 = r965971 * r965975;
return r965976;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.2 |
|---|---|
| Target | 26.1 |
| Herbie | 0.4 |
Initial program 38.2
rmApplied div-inv38.3
Applied sqrt-prod38.3
rmApplied add-sqr-sqrt38.3
Applied hypot-def29.4
rmApplied hypot-def0.4
Final simplification0.4
herbie shell --seed 2020047 +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)))