\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 3.7682365661707411 \cdot 10^{-288}:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;x \cdot x + y \cdot y \le 6.36921913743591853 \cdot 10^{78}:\\
\;\;\;\;\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 9.21234681244353091 \cdot 10^{127}:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;x \cdot x + y \cdot y \le 7.3089500670956082 \cdot 10^{304}:\\
\;\;\;\;\left|\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{\sqrt{3}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|-\frac{x}{\sqrt{3}}\right|\\
\end{array}double f(double x, double y, double z) {
double r855750 = x;
double r855751 = r855750 * r855750;
double r855752 = y;
double r855753 = r855752 * r855752;
double r855754 = r855751 + r855753;
double r855755 = z;
double r855756 = r855755 * r855755;
double r855757 = r855754 + r855756;
double r855758 = 3.0;
double r855759 = r855757 / r855758;
double r855760 = sqrt(r855759);
return r855760;
}
double f(double x, double y, double z) {
double r855761 = x;
double r855762 = r855761 * r855761;
double r855763 = y;
double r855764 = r855763 * r855763;
double r855765 = r855762 + r855764;
double r855766 = 3.768236566170741e-288;
bool r855767 = r855765 <= r855766;
double r855768 = z;
double r855769 = 3.0;
double r855770 = sqrt(r855769);
double r855771 = r855768 / r855770;
double r855772 = fabs(r855771);
double r855773 = 6.3692191374359185e+78;
bool r855774 = r855765 <= r855773;
double r855775 = r855768 * r855768;
double r855776 = r855765 + r855775;
double r855777 = sqrt(r855776);
double r855778 = 1.0;
double r855779 = r855778 / r855769;
double r855780 = sqrt(r855779);
double r855781 = r855777 * r855780;
double r855782 = 9.21234681244353e+127;
bool r855783 = r855765 <= r855782;
double r855784 = 7.308950067095608e+304;
bool r855785 = r855765 <= r855784;
double r855786 = r855777 / r855770;
double r855787 = fabs(r855786);
double r855788 = r855761 / r855770;
double r855789 = -r855788;
double r855790 = fabs(r855789);
double r855791 = r855785 ? r855787 : r855790;
double r855792 = r855783 ? r855772 : r855791;
double r855793 = r855774 ? r855781 : r855792;
double r855794 = r855767 ? r855772 : r855793;
return r855794;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.2 |
|---|---|
| Target | 26.1 |
| Herbie | 24.4 |
if (+ (* x x) (* y y)) < 3.768236566170741e-288 or 6.3692191374359185e+78 < (+ (* x x) (* y y)) < 9.21234681244353e+127Initial program 23.9
rmApplied add-sqr-sqrt24.1
Applied add-sqr-sqrt24.1
Applied times-frac24.0
Applied rem-sqrt-square24.0
Taylor expanded around 0 19.1
if 3.768236566170741e-288 < (+ (* x x) (* y y)) < 6.3692191374359185e+78Initial program 15.7
rmApplied div-inv15.7
Applied sqrt-prod15.9
if 9.21234681244353e+127 < (+ (* x x) (* y y)) < 7.308950067095608e+304Initial program 15.6
rmApplied add-sqr-sqrt15.9
Applied add-sqr-sqrt15.9
Applied times-frac15.8
Applied rem-sqrt-square15.8
if 7.308950067095608e+304 < (+ (* x x) (* y y)) Initial program 63.6
rmApplied add-sqr-sqrt63.6
Applied add-sqr-sqrt63.6
Applied times-frac63.6
Applied rem-sqrt-square63.6
Taylor expanded around -inf 33.9
Simplified33.9
Final simplification24.4
herbie shell --seed 2020047
(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)))