\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3.0}}\begin{array}{l}
\mathbf{if}\;y \le -1.3282248930815427 \cdot 10^{+154}:\\
\;\;\;\;\sqrt{0.3333333333333333} \cdot \left(-y\right)\\
\mathbf{elif}\;y \le 8.243533173233274 \cdot 10^{+154}:\\
\;\;\;\;\sqrt{\frac{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, z \cdot z\right)\right)}{3.0}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.3333333333333333} \cdot y\\
\end{array}double f(double x, double y, double z) {
double r31028415 = x;
double r31028416 = r31028415 * r31028415;
double r31028417 = y;
double r31028418 = r31028417 * r31028417;
double r31028419 = r31028416 + r31028418;
double r31028420 = z;
double r31028421 = r31028420 * r31028420;
double r31028422 = r31028419 + r31028421;
double r31028423 = 3.0;
double r31028424 = r31028422 / r31028423;
double r31028425 = sqrt(r31028424);
return r31028425;
}
double f(double x, double y, double z) {
double r31028426 = y;
double r31028427 = -1.3282248930815427e+154;
bool r31028428 = r31028426 <= r31028427;
double r31028429 = 0.3333333333333333;
double r31028430 = sqrt(r31028429);
double r31028431 = -r31028426;
double r31028432 = r31028430 * r31028431;
double r31028433 = 8.243533173233274e+154;
bool r31028434 = r31028426 <= r31028433;
double r31028435 = x;
double r31028436 = z;
double r31028437 = r31028436 * r31028436;
double r31028438 = fma(r31028435, r31028435, r31028437);
double r31028439 = fma(r31028426, r31028426, r31028438);
double r31028440 = 3.0;
double r31028441 = r31028439 / r31028440;
double r31028442 = sqrt(r31028441);
double r31028443 = r31028430 * r31028426;
double r31028444 = r31028434 ? r31028442 : r31028443;
double r31028445 = r31028428 ? r31028432 : r31028444;
return r31028445;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 35.7 |
|---|---|
| Target | 24.6 |
| Herbie | 24.3 |
if y < -1.3282248930815427e+154Initial program 59.3
Simplified59.3
rmApplied *-un-lft-identity59.3
Applied add-sqr-sqrt59.3
Applied times-frac59.3
Applied sqrt-prod59.3
rmApplied div-inv59.3
Applied sqrt-prod59.3
Applied associate-*r*59.3
Simplified59.3
Taylor expanded around -inf 14.2
Simplified14.2
if -1.3282248930815427e+154 < y < 8.243533173233274e+154Initial program 27.7
Simplified27.7
if 8.243533173233274e+154 < y Initial program 59.3
Simplified59.3
Taylor expanded around inf 14.4
Final simplification24.3
herbie shell --seed 2019163 +o rules:numerics
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.Pixel:doubleRmsOfRGB8 from repa-algorithms-3.4.0.1"
:herbie-target
(if (< z -6.396479394109776e+136) (/ (- z) (sqrt 3.0)) (if (< z 7.320293694404182e+117) (/ (sqrt (+ (+ (* z z) (* x x)) (* y y))) (sqrt 3.0)) (* (sqrt 0.3333333333333333) z)))
(sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))