\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\left|\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\sqrt{3}}\right|double f(double x, double y, double z) {
double r883632 = x;
double r883633 = r883632 * r883632;
double r883634 = y;
double r883635 = r883634 * r883634;
double r883636 = r883633 + r883635;
double r883637 = z;
double r883638 = r883637 * r883637;
double r883639 = r883636 + r883638;
double r883640 = 3.0;
double r883641 = r883639 / r883640;
double r883642 = sqrt(r883641);
return r883642;
}
double f(double x, double y, double z) {
double r883643 = x;
double r883644 = y;
double r883645 = hypot(r883643, r883644);
double r883646 = z;
double r883647 = hypot(r883645, r883646);
double r883648 = 3.0;
double r883649 = sqrt(r883648);
double r883650 = r883647 / r883649;
double r883651 = fabs(r883650);
return r883651;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.1 |
|---|---|
| Target | 26.0 |
| Herbie | 0.4 |
Initial program 38.1
rmApplied add-sqr-sqrt38.2
Applied add-sqr-sqrt38.2
Applied times-frac38.2
Applied rem-sqrt-square38.2
rmApplied add-sqr-sqrt38.2
Applied hypot-def28.9
rmApplied *-un-lft-identity28.9
Applied *-un-lft-identity28.9
Applied times-frac28.9
Simplified28.9
Simplified0.4
Final simplification0.4
herbie shell --seed 2020043 +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)))