\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 0.0:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;x \cdot x + y \cdot y \le 9.123040389468657471064841380531675193627 \cdot 10^{304}:\\
\;\;\;\;\sqrt{0.3333333333333333148296162562473909929395 \cdot \left(\left(x \cdot x + y \cdot y\right) + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\sqrt{3}}\right|\\
\end{array}double f(double x, double y, double z) {
double r595641 = x;
double r595642 = r595641 * r595641;
double r595643 = y;
double r595644 = r595643 * r595643;
double r595645 = r595642 + r595644;
double r595646 = z;
double r595647 = r595646 * r595646;
double r595648 = r595645 + r595647;
double r595649 = 3.0;
double r595650 = r595648 / r595649;
double r595651 = sqrt(r595650);
return r595651;
}
double f(double x, double y, double z) {
double r595652 = x;
double r595653 = r595652 * r595652;
double r595654 = y;
double r595655 = r595654 * r595654;
double r595656 = r595653 + r595655;
double r595657 = 0.0;
bool r595658 = r595656 <= r595657;
double r595659 = z;
double r595660 = 3.0;
double r595661 = sqrt(r595660);
double r595662 = r595659 / r595661;
double r595663 = fabs(r595662);
double r595664 = 9.123040389468657e+304;
bool r595665 = r595656 <= r595664;
double r595666 = 0.3333333333333333;
double r595667 = r595659 * r595659;
double r595668 = r595656 + r595667;
double r595669 = r595666 * r595668;
double r595670 = sqrt(r595669);
double r595671 = r595652 / r595661;
double r595672 = fabs(r595671);
double r595673 = r595665 ? r595670 : r595672;
double r595674 = r595658 ? r595663 : r595673;
return r595674;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.8 |
|---|---|
| Target | 25.7 |
| Herbie | 23.8 |
if (+ (* x x) (* y y)) < 0.0Initial program 30.8
rmApplied add-sqr-sqrt31.0
Applied add-sqr-sqrt31.0
Applied times-frac31.0
Applied rem-sqrt-square31.0
Taylor expanded around 0 8.7
if 0.0 < (+ (* x x) (* y y)) < 9.123040389468657e+304Initial program 15.7
Taylor expanded around 0 15.7
Simplified15.7
if 9.123040389468657e+304 < (+ (* x x) (* y y)) Initial program 63.7
rmApplied add-sqr-sqrt63.8
Applied add-sqr-sqrt63.8
Applied times-frac63.8
Applied rem-sqrt-square63.8
Taylor expanded around inf 34.9
Final simplification23.8
herbie shell --seed 2019306
(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.3964793941097758e136) (/ (- z) (sqrt 3)) (if (< z 7.3202936944041821e117) (/ (sqrt (+ (+ (* z z) (* x x)) (* y y))) (sqrt 3)) (* (sqrt 0.333333333333333315) z)))
(sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3)))