\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 2.31575969133539379 \cdot 10^{-234}:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;x \cdot x + y \cdot y \le 6.707815176943637 \cdot 10^{92}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \cdot \sqrt{\frac{1}{3}}\\
\mathbf{elif}\;x \cdot x + y \cdot y \le 3.85879325329768613 \cdot 10^{129}:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;x \cdot x + y \cdot y \le 2.26629948981050773 \cdot 10^{307}:\\
\;\;\;\;\left|\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{\sqrt{3}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|-1 \cdot \frac{x}{\sqrt{3}}\right|\\
\end{array}double f(double x, double y, double z) {
double r835827 = x;
double r835828 = r835827 * r835827;
double r835829 = y;
double r835830 = r835829 * r835829;
double r835831 = r835828 + r835830;
double r835832 = z;
double r835833 = r835832 * r835832;
double r835834 = r835831 + r835833;
double r835835 = 3.0;
double r835836 = r835834 / r835835;
double r835837 = sqrt(r835836);
return r835837;
}
double f(double x, double y, double z) {
double r835838 = x;
double r835839 = r835838 * r835838;
double r835840 = y;
double r835841 = r835840 * r835840;
double r835842 = r835839 + r835841;
double r835843 = 2.3157596913353938e-234;
bool r835844 = r835842 <= r835843;
double r835845 = z;
double r835846 = 3.0;
double r835847 = sqrt(r835846);
double r835848 = r835845 / r835847;
double r835849 = fabs(r835848);
double r835850 = 6.707815176943637e+92;
bool r835851 = r835842 <= r835850;
double r835852 = r835845 * r835845;
double r835853 = r835842 + r835852;
double r835854 = sqrt(r835853);
double r835855 = 1.0;
double r835856 = r835855 / r835846;
double r835857 = sqrt(r835856);
double r835858 = r835854 * r835857;
double r835859 = 3.858793253297686e+129;
bool r835860 = r835842 <= r835859;
double r835861 = 2.2662994898105077e+307;
bool r835862 = r835842 <= r835861;
double r835863 = r835854 / r835847;
double r835864 = fabs(r835863);
double r835865 = -1.0;
double r835866 = r835838 / r835847;
double r835867 = r835865 * r835866;
double r835868 = fabs(r835867);
double r835869 = r835862 ? r835864 : r835868;
double r835870 = r835860 ? r835849 : r835869;
double r835871 = r835851 ? r835858 : r835870;
double r835872 = r835844 ? r835849 : r835871;
return r835872;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.4 |
|---|---|
| Target | 26.0 |
| Herbie | 25.0 |
if (+ (* x x) (* y y)) < 2.3157596913353938e-234 or 6.707815176943637e+92 < (+ (* x x) (* y y)) < 3.858793253297686e+129Initial program 23.9
rmApplied add-sqr-sqrt24.0
Applied add-sqr-sqrt24.0
Applied times-frac24.0
Applied rem-sqrt-square23.9
Taylor expanded around 0 18.5
if 2.3157596913353938e-234 < (+ (* x x) (* y y)) < 6.707815176943637e+92Initial program 15.6
rmApplied div-inv15.6
Applied sqrt-prod15.7
if 3.858793253297686e+129 < (+ (* x x) (* y y)) < 2.2662994898105077e+307Initial program 17.3
rmApplied add-sqr-sqrt17.5
Applied add-sqr-sqrt17.5
Applied times-frac17.4
Applied rem-sqrt-square17.4
if 2.2662994898105077e+307 < (+ (* x x) (* y y)) Initial program 63.9
rmApplied add-sqr-sqrt63.9
Applied add-sqr-sqrt63.9
Applied times-frac63.9
Applied rem-sqrt-square63.9
Taylor expanded around -inf 35.0
Final simplification25.0
herbie shell --seed 2020083
(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)))