\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;y \le -1.717333272640103545901465763102229690483 \cdot 10^{89}:\\
\;\;\;\;\left(-y\right) \cdot \sqrt{0.3333333333333333148296162562473909929395}\\
\mathbf{elif}\;y \le 2.673911141236909644899525953792608723737 \cdot 10^{-195}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, {z}^{2}\right)\right) \cdot 0.3333333333333333148296162562473909929395}\\
\mathbf{elif}\;y \le 3.267479005742163364041445759339258528358 \cdot 10^{-158}:\\
\;\;\;\;\sqrt{0.3333333333333333148296162562473909929395} \cdot z\\
\mathbf{elif}\;y \le 1.902370008063671102963145796212009492267 \cdot 10^{138}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, {z}^{2}\right)\right) \cdot 0.3333333333333333148296162562473909929395}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.3333333333333333148296162562473909929395} \cdot y\\
\end{array}double f(double x, double y, double z) {
double r661400 = x;
double r661401 = r661400 * r661400;
double r661402 = y;
double r661403 = r661402 * r661402;
double r661404 = r661401 + r661403;
double r661405 = z;
double r661406 = r661405 * r661405;
double r661407 = r661404 + r661406;
double r661408 = 3.0;
double r661409 = r661407 / r661408;
double r661410 = sqrt(r661409);
return r661410;
}
double f(double x, double y, double z) {
double r661411 = y;
double r661412 = -1.7173332726401035e+89;
bool r661413 = r661411 <= r661412;
double r661414 = -r661411;
double r661415 = 0.3333333333333333;
double r661416 = sqrt(r661415);
double r661417 = r661414 * r661416;
double r661418 = 2.6739111412369096e-195;
bool r661419 = r661411 <= r661418;
double r661420 = x;
double r661421 = z;
double r661422 = 2.0;
double r661423 = pow(r661421, r661422);
double r661424 = fma(r661420, r661420, r661423);
double r661425 = fma(r661411, r661411, r661424);
double r661426 = r661425 * r661415;
double r661427 = sqrt(r661426);
double r661428 = 3.2674790057421634e-158;
bool r661429 = r661411 <= r661428;
double r661430 = r661416 * r661421;
double r661431 = 1.902370008063671e+138;
bool r661432 = r661411 <= r661431;
double r661433 = r661416 * r661411;
double r661434 = r661432 ? r661427 : r661433;
double r661435 = r661429 ? r661430 : r661434;
double r661436 = r661419 ? r661427 : r661435;
double r661437 = r661413 ? r661417 : r661436;
return r661437;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 37.8 |
|---|---|
| Target | 25.8 |
| Herbie | 25.9 |
if y < -1.7173332726401035e+89Initial program 53.6
Simplified53.6
rmApplied add-cube-cbrt53.6
Applied add-sqr-sqrt53.6
Applied times-frac53.6
Simplified53.6
Simplified53.6
Taylor expanded around -inf 19.4
Simplified19.4
if -1.7173332726401035e+89 < y < 2.6739111412369096e-195 or 3.2674790057421634e-158 < y < 1.902370008063671e+138Initial program 28.9
Simplified28.9
Taylor expanded around 0 28.9
Simplified28.9
if 2.6739111412369096e-195 < y < 3.2674790057421634e-158Initial program 33.2
Simplified33.2
rmApplied add-cube-cbrt33.2
Applied add-sqr-sqrt33.2
Applied times-frac33.3
Simplified33.3
Simplified33.3
Taylor expanded around 0 48.1
if 1.902370008063671e+138 < y Initial program 60.7
Simplified60.7
Taylor expanded around inf 14.9
Final simplification25.9
herbie shell --seed 2019194 +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)))