\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\left(\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \mathsf{hypot}\left(1 \cdot \mathsf{hypot}\left(x, y\right), z\right)\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}double f(double x, double y, double z) {
double r837171 = x;
double r837172 = r837171 * r837171;
double r837173 = y;
double r837174 = r837173 * r837173;
double r837175 = r837172 + r837174;
double r837176 = z;
double r837177 = r837176 * r837176;
double r837178 = r837175 + r837177;
double r837179 = 3.0;
double r837180 = r837178 / r837179;
double r837181 = sqrt(r837180);
return r837181;
}
double f(double x, double y, double z) {
double r837182 = 1.0;
double r837183 = 3.0;
double r837184 = cbrt(r837183);
double r837185 = r837184 * r837184;
double r837186 = r837182 / r837185;
double r837187 = sqrt(r837186);
double r837188 = x;
double r837189 = y;
double r837190 = hypot(r837188, r837189);
double r837191 = r837182 * r837190;
double r837192 = z;
double r837193 = hypot(r837191, r837192);
double r837194 = r837187 * r837193;
double r837195 = r837182 / r837184;
double r837196 = sqrt(r837195);
double r837197 = r837194 * r837196;
return r837197;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.1 |
|---|---|
| Target | 26.0 |
| Herbie | 0.3 |
Initial program 38.1
rmApplied add-cube-cbrt38.1
Applied *-un-lft-identity38.1
Applied times-frac38.1
Applied sqrt-prod38.1
rmApplied div-inv38.1
Applied sqrt-prod38.1
Applied associate-*r*38.1
rmApplied add-sqr-sqrt38.1
Applied hypot-def29.0
rmApplied *-un-lft-identity29.0
Applied sqrt-prod29.0
Simplified29.0
Simplified0.3
Final simplification0.3
herbie shell --seed 2020001 +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)))