\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right) \cdot \sqrt{\frac{1}{3}}double f(double x, double y, double z) {
double r745654 = x;
double r745655 = r745654 * r745654;
double r745656 = y;
double r745657 = r745656 * r745656;
double r745658 = r745655 + r745657;
double r745659 = z;
double r745660 = r745659 * r745659;
double r745661 = r745658 + r745660;
double r745662 = 3.0;
double r745663 = r745661 / r745662;
double r745664 = sqrt(r745663);
return r745664;
}
double f(double x, double y, double z) {
double r745665 = x;
double r745666 = y;
double r745667 = hypot(r745665, r745666);
double r745668 = z;
double r745669 = hypot(r745667, r745668);
double r745670 = 1.0;
double r745671 = 3.0;
double r745672 = r745670 / r745671;
double r745673 = sqrt(r745672);
double r745674 = r745669 * r745673;
return r745674;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.5 |
|---|---|
| Target | 26.3 |
| Herbie | 0.4 |
Initial program 38.5
rmApplied div-inv38.5
Applied sqrt-prod38.5
rmApplied add-sqr-sqrt38.5
Applied hypot-def29.5
rmApplied hypot-def0.4
Final simplification0.4
herbie shell --seed 2020034 +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)))