\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;z \le -5.86376436625527096038425827064555139232 \cdot 10^{94}:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;z \le 5.479034299166120282419679868368698216953 \cdot 10^{-62}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \cdot \sqrt{\frac{1}{3}}\\
\mathbf{elif}\;z \le 1.43555553142026435386156201253954068939 \cdot 10^{-23}:\\
\;\;\;\;\left|-1 \cdot \frac{x}{\sqrt{3}}\right|\\
\mathbf{elif}\;z \le 3.353544466640978225465484641144922282532 \cdot 10^{127}:\\
\;\;\;\;\left|\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{\sqrt{3}}\right|\\
\mathbf{else}:\\
\;\;\;\;z \cdot \sqrt{\frac{1}{3}}\\
\end{array}double f(double x, double y, double z) {
double r889662 = x;
double r889663 = r889662 * r889662;
double r889664 = y;
double r889665 = r889664 * r889664;
double r889666 = r889663 + r889665;
double r889667 = z;
double r889668 = r889667 * r889667;
double r889669 = r889666 + r889668;
double r889670 = 3.0;
double r889671 = r889669 / r889670;
double r889672 = sqrt(r889671);
return r889672;
}
double f(double x, double y, double z) {
double r889673 = z;
double r889674 = -5.863764366255271e+94;
bool r889675 = r889673 <= r889674;
double r889676 = 3.0;
double r889677 = sqrt(r889676);
double r889678 = r889673 / r889677;
double r889679 = fabs(r889678);
double r889680 = 5.47903429916612e-62;
bool r889681 = r889673 <= r889680;
double r889682 = x;
double r889683 = r889682 * r889682;
double r889684 = y;
double r889685 = r889684 * r889684;
double r889686 = r889683 + r889685;
double r889687 = r889673 * r889673;
double r889688 = r889686 + r889687;
double r889689 = sqrt(r889688);
double r889690 = 1.0;
double r889691 = r889690 / r889676;
double r889692 = sqrt(r889691);
double r889693 = r889689 * r889692;
double r889694 = 1.4355555314202644e-23;
bool r889695 = r889673 <= r889694;
double r889696 = -1.0;
double r889697 = r889682 / r889677;
double r889698 = r889696 * r889697;
double r889699 = fabs(r889698);
double r889700 = 3.353544466640978e+127;
bool r889701 = r889673 <= r889700;
double r889702 = r889689 / r889677;
double r889703 = fabs(r889702);
double r889704 = r889673 * r889692;
double r889705 = r889701 ? r889703 : r889704;
double r889706 = r889695 ? r889699 : r889705;
double r889707 = r889681 ? r889693 : r889706;
double r889708 = r889675 ? r889679 : r889707;
return r889708;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 39.0 |
|---|---|
| Target | 26.3 |
| Herbie | 26.5 |
if z < -5.863764366255271e+94Initial program 55.0
rmApplied add-sqr-sqrt55.0
Applied add-sqr-sqrt55.0
Applied times-frac55.0
Applied rem-sqrt-square55.0
Taylor expanded around 0 19.7
if -5.863764366255271e+94 < z < 5.47903429916612e-62Initial program 30.7
rmApplied div-inv30.7
Applied sqrt-prod30.8
if 5.47903429916612e-62 < z < 1.4355555314202644e-23Initial program 30.8
rmApplied add-sqr-sqrt30.9
Applied add-sqr-sqrt30.9
Applied times-frac30.9
Applied rem-sqrt-square30.9
rmApplied add-exp-log30.9
Applied add-exp-log33.1
Applied div-exp33.2
Simplified33.1
Taylor expanded around -inf 34.2
if 1.4355555314202644e-23 < z < 3.353544466640978e+127Initial program 28.9
rmApplied add-sqr-sqrt29.1
Applied add-sqr-sqrt29.1
Applied times-frac29.0
Applied rem-sqrt-square29.0
if 3.353544466640978e+127 < z Initial program 58.6
rmApplied div-inv58.6
Applied sqrt-prod58.6
Taylor expanded around 0 15.9
Final simplification26.5
herbie shell --seed 2020002
(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)))