\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 r776027 = x;
double r776028 = r776027 * r776027;
double r776029 = y;
double r776030 = r776029 * r776029;
double r776031 = r776028 + r776030;
double r776032 = z;
double r776033 = r776032 * r776032;
double r776034 = r776031 + r776033;
double r776035 = 3.0;
double r776036 = r776034 / r776035;
double r776037 = sqrt(r776036);
return r776037;
}
double f(double x, double y, double z) {
double r776038 = 1.0;
double r776039 = 3.0;
double r776040 = cbrt(r776039);
double r776041 = r776040 * r776040;
double r776042 = r776038 / r776041;
double r776043 = sqrt(r776042);
double r776044 = x;
double r776045 = y;
double r776046 = hypot(r776044, r776045);
double r776047 = r776038 * r776046;
double r776048 = z;
double r776049 = hypot(r776047, r776048);
double r776050 = r776043 * r776049;
double r776051 = r776038 / r776040;
double r776052 = sqrt(r776051);
double r776053 = r776050 * r776052;
return r776053;
}




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)))