\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\left|\frac{\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\left|\sqrt[3]{3}\right|}}{\sqrt{\sqrt[3]{3}}}\right|double f(double x, double y, double z) {
double r1037007 = x;
double r1037008 = r1037007 * r1037007;
double r1037009 = y;
double r1037010 = r1037009 * r1037009;
double r1037011 = r1037008 + r1037010;
double r1037012 = z;
double r1037013 = r1037012 * r1037012;
double r1037014 = r1037011 + r1037013;
double r1037015 = 3.0;
double r1037016 = r1037014 / r1037015;
double r1037017 = sqrt(r1037016);
return r1037017;
}
double f(double x, double y, double z) {
double r1037018 = x;
double r1037019 = y;
double r1037020 = hypot(r1037018, r1037019);
double r1037021 = z;
double r1037022 = hypot(r1037020, r1037021);
double r1037023 = 3.0;
double r1037024 = cbrt(r1037023);
double r1037025 = fabs(r1037024);
double r1037026 = r1037022 / r1037025;
double r1037027 = sqrt(r1037024);
double r1037028 = r1037026 / r1037027;
double r1037029 = fabs(r1037028);
return r1037029;
}




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 add-sqr-sqrt37.9
Applied add-sqr-sqrt37.9
Applied times-frac37.9
Applied rem-sqrt-square37.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)))