\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 f(double x, double y, double z) {
double r973262 = x;
double r973263 = r973262 * r973262;
double r973264 = y;
double r973265 = r973264 * r973264;
double r973266 = r973263 + r973265;
double r973267 = z;
double r973268 = r973267 * r973267;
double r973269 = r973266 + r973268;
double r973270 = 3.0;
double r973271 = r973269 / r973270;
double r973272 = sqrt(r973271);
return r973272;
}
double f(double x, double y, double z) {
double r973273 = x;
double r973274 = y;
double r973275 = hypot(r973273, r973274);
double r973276 = z;
double r973277 = hypot(r973275, r973276);
double r973278 = 3.0;
double r973279 = cbrt(r973278);
double r973280 = fabs(r973279);
double r973281 = r973277 / r973280;
double r973282 = sqrt(r973279);
double r973283 = r973281 / r973282;
return r973283;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.8 |
|---|---|
| Target | 25.7 |
| Herbie | 0.4 |
Initial program 37.8
rmApplied sqrt-div37.9
rmApplied add-sqr-sqrt37.9
Applied hypot-def28.8
rmApplied hypot-def0.4
rmApplied add-cube-cbrt0.4
Applied sqrt-prod0.4
Applied associate-/r*0.4
Simplified0.4
Final simplification0.4
herbie shell --seed 2019353 +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)))