\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;x \cdot x + y \cdot y \le 9.5571349373151974 \cdot 10^{307}:\\
\;\;\;\;\left|\frac{\mathsf{hypot}\left(\sqrt{x \cdot x + y \cdot y}, z\right)}{\sqrt{3}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-x}{\sqrt{3}}\right|\\
\end{array}double f(double x, double y, double z) {
double r1049756 = x;
double r1049757 = r1049756 * r1049756;
double r1049758 = y;
double r1049759 = r1049758 * r1049758;
double r1049760 = r1049757 + r1049759;
double r1049761 = z;
double r1049762 = r1049761 * r1049761;
double r1049763 = r1049760 + r1049762;
double r1049764 = 3.0;
double r1049765 = r1049763 / r1049764;
double r1049766 = sqrt(r1049765);
return r1049766;
}
double f(double x, double y, double z) {
double r1049767 = x;
double r1049768 = r1049767 * r1049767;
double r1049769 = y;
double r1049770 = r1049769 * r1049769;
double r1049771 = r1049768 + r1049770;
double r1049772 = 9.557134937315197e+307;
bool r1049773 = r1049771 <= r1049772;
double r1049774 = sqrt(r1049771);
double r1049775 = z;
double r1049776 = hypot(r1049774, r1049775);
double r1049777 = 3.0;
double r1049778 = sqrt(r1049777);
double r1049779 = r1049776 / r1049778;
double r1049780 = fabs(r1049779);
double r1049781 = -r1049767;
double r1049782 = r1049781 / r1049778;
double r1049783 = fabs(r1049782);
double r1049784 = r1049773 ? r1049780 : r1049783;
return r1049784;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.7 |
|---|---|
| Target | 25.8 |
| Herbie | 15.7 |
if (+ (* x x) (* y y)) < 9.557134937315197e+307Initial program 17.1
rmApplied add-sqr-sqrt17.3
Applied add-sqr-sqrt17.3
Applied times-frac17.3
Applied rem-sqrt-square17.3
rmApplied add-sqr-sqrt17.3
Applied hypot-def1.4
if 9.557134937315197e+307 < (+ (* x x) (* y y)) Initial program 64.0
rmApplied add-sqr-sqrt64.0
Applied add-sqr-sqrt64.0
Applied times-frac64.0
Applied rem-sqrt-square64.0
Taylor expanded around -inf 34.0
Simplified34.0
Final simplification15.7
herbie shell --seed 2020045 +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)))