\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;y \cdot y \le 4.439426932358056857070177144442333215206 \cdot 10^{-209}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(z, z, \mathsf{fma}\left(x, x, y \cdot y\right)\right)} \cdot \sqrt{\frac{1}{3}}\\
\mathbf{elif}\;y \cdot y \le 3.175284095555138930133331201720651244119 \cdot 10^{-175}:\\
\;\;\;\;\left|\frac{-z}{\sqrt{3}}\right|\\
\mathbf{elif}\;y \cdot y \le 123213193343404294518476252381184:\\
\;\;\;\;\left|\frac{\sqrt{\mathsf{fma}\left(z, z, \mathsf{fma}\left(x, x, y \cdot y\right)\right)}}{\sqrt{3}}\right|\\
\mathbf{elif}\;y \cdot y \le 7.236242921693302431325514422666640935777 \cdot 10^{54}:\\
\;\;\;\;\left|\frac{-z}{\sqrt{3}}\right|\\
\mathbf{elif}\;y \cdot y \le 1.596754056659774816555212493880410624898 \cdot 10^{244}:\\
\;\;\;\;\left|\frac{\sqrt{\mathsf{fma}\left(z, z, \mathsf{fma}\left(x, x, y \cdot y\right)\right)}}{\sqrt{3}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{y}{\sqrt{3}}\right|\\
\end{array}double f(double x, double y, double z) {
double r648328 = x;
double r648329 = r648328 * r648328;
double r648330 = y;
double r648331 = r648330 * r648330;
double r648332 = r648329 + r648331;
double r648333 = z;
double r648334 = r648333 * r648333;
double r648335 = r648332 + r648334;
double r648336 = 3.0;
double r648337 = r648335 / r648336;
double r648338 = sqrt(r648337);
return r648338;
}
double f(double x, double y, double z) {
double r648339 = y;
double r648340 = r648339 * r648339;
double r648341 = 4.439426932358057e-209;
bool r648342 = r648340 <= r648341;
double r648343 = z;
double r648344 = x;
double r648345 = fma(r648344, r648344, r648340);
double r648346 = fma(r648343, r648343, r648345);
double r648347 = sqrt(r648346);
double r648348 = 1.0;
double r648349 = 3.0;
double r648350 = r648348 / r648349;
double r648351 = sqrt(r648350);
double r648352 = r648347 * r648351;
double r648353 = 3.175284095555139e-175;
bool r648354 = r648340 <= r648353;
double r648355 = -r648343;
double r648356 = sqrt(r648349);
double r648357 = r648355 / r648356;
double r648358 = fabs(r648357);
double r648359 = 1.232131933434043e+32;
bool r648360 = r648340 <= r648359;
double r648361 = r648347 / r648356;
double r648362 = fabs(r648361);
double r648363 = 7.236242921693302e+54;
bool r648364 = r648340 <= r648363;
double r648365 = 1.5967540566597748e+244;
bool r648366 = r648340 <= r648365;
double r648367 = r648339 / r648356;
double r648368 = fabs(r648367);
double r648369 = r648366 ? r648362 : r648368;
double r648370 = r648364 ? r648358 : r648369;
double r648371 = r648360 ? r648362 : r648370;
double r648372 = r648354 ? r648358 : r648371;
double r648373 = r648342 ? r648352 : r648372;
return r648373;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 37.8 |
|---|---|
| Target | 25.5 |
| Herbie | 26.3 |
if (* y y) < 4.439426932358057e-209Initial program 30.5
Simplified30.5
rmApplied div-inv30.6
Applied sqrt-prod30.6
if 4.439426932358057e-209 < (* y y) < 3.175284095555139e-175 or 1.232131933434043e+32 < (* y y) < 7.236242921693302e+54Initial program 28.1
Simplified28.1
rmApplied add-sqr-sqrt28.3
Applied add-sqr-sqrt28.3
Applied times-frac28.2
Applied rem-sqrt-square28.2
Taylor expanded around -inf 36.9
Simplified36.9
if 3.175284095555139e-175 < (* y y) < 1.232131933434043e+32 or 7.236242921693302e+54 < (* y y) < 1.5967540566597748e+244Initial program 28.0
Simplified28.0
rmApplied add-sqr-sqrt28.2
Applied add-sqr-sqrt28.2
Applied times-frac28.2
Applied rem-sqrt-square28.2
if 1.5967540566597748e+244 < (* y y) Initial program 57.8
Simplified57.8
rmApplied add-sqr-sqrt57.8
Applied add-sqr-sqrt57.8
Applied times-frac57.8
Applied rem-sqrt-square57.8
Taylor expanded around 0 17.9
Final simplification26.3
herbie shell --seed 2019212 +o rules:numerics
(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)))