\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\frac{\mathsf{hypot}\left(1 \cdot \mathsf{hypot}\left(x, y\right), z\right)}{\sqrt{3}}double f(double x, double y, double z) {
double r906060 = x;
double r906061 = r906060 * r906060;
double r906062 = y;
double r906063 = r906062 * r906062;
double r906064 = r906061 + r906063;
double r906065 = z;
double r906066 = r906065 * r906065;
double r906067 = r906064 + r906066;
double r906068 = 3.0;
double r906069 = r906067 / r906068;
double r906070 = sqrt(r906069);
return r906070;
}
double f(double x, double y, double z) {
double r906071 = 1.0;
double r906072 = x;
double r906073 = y;
double r906074 = hypot(r906072, r906073);
double r906075 = r906071 * r906074;
double r906076 = z;
double r906077 = hypot(r906075, r906076);
double r906078 = 3.0;
double r906079 = sqrt(r906078);
double r906080 = r906077 / r906079;
return r906080;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.3 |
|---|---|
| Target | 25.7 |
| Herbie | 0.4 |
Initial program 38.3
rmApplied sqrt-div38.4
rmApplied add-sqr-sqrt38.4
Applied hypot-def28.9
rmApplied *-un-lft-identity28.9
Applied sqrt-prod28.9
Simplified28.9
Simplified0.4
Final simplification0.4
herbie shell --seed 2020036 +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)))