\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;x \le -1.16634249568808763 \cdot 10^{121}:\\
\;\;\;\;\frac{-x}{\sqrt{3}}\\
\mathbf{elif}\;x \le 1.1586965865467858 \cdot 10^{60}:\\
\;\;\;\;\sqrt{0.333333333333333315 \cdot \left(\left(x \cdot x + y \cdot y\right) + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \sqrt{\frac{1}{3}}\\
\end{array}double f(double x, double y, double z) {
double r826708 = x;
double r826709 = r826708 * r826708;
double r826710 = y;
double r826711 = r826710 * r826710;
double r826712 = r826709 + r826711;
double r826713 = z;
double r826714 = r826713 * r826713;
double r826715 = r826712 + r826714;
double r826716 = 3.0;
double r826717 = r826715 / r826716;
double r826718 = sqrt(r826717);
return r826718;
}
double f(double x, double y, double z) {
double r826719 = x;
double r826720 = -1.1663424956880876e+121;
bool r826721 = r826719 <= r826720;
double r826722 = -r826719;
double r826723 = 3.0;
double r826724 = sqrt(r826723);
double r826725 = r826722 / r826724;
double r826726 = 1.1586965865467858e+60;
bool r826727 = r826719 <= r826726;
double r826728 = 0.3333333333333333;
double r826729 = r826719 * r826719;
double r826730 = y;
double r826731 = r826730 * r826730;
double r826732 = r826729 + r826731;
double r826733 = z;
double r826734 = r826733 * r826733;
double r826735 = r826732 + r826734;
double r826736 = r826728 * r826735;
double r826737 = sqrt(r826736);
double r826738 = 1.0;
double r826739 = r826738 / r826723;
double r826740 = sqrt(r826739);
double r826741 = r826719 * r826740;
double r826742 = r826727 ? r826737 : r826741;
double r826743 = r826721 ? r826725 : r826742;
return r826743;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.7 |
|---|---|
| Target | 25.8 |
| Herbie | 25.3 |
if x < -1.1663424956880876e+121Initial program 57.8
rmApplied div-inv57.8
Applied sqrt-prod57.8
rmApplied sqrt-div57.8
Applied associate-*r/57.8
Simplified57.8
Taylor expanded around -inf 16.5
Simplified16.5
if -1.1663424956880876e+121 < x < 1.1586965865467858e+60Initial program 29.0
Taylor expanded around 0 29.0
Simplified29.0
if 1.1586965865467858e+60 < x Initial program 50.1
rmApplied div-inv50.1
Applied sqrt-prod50.1
Taylor expanded around inf 20.4
Final simplification25.3
herbie shell --seed 2020045
(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)))