\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;z \le -3.74693859576126102544728952505913367202 \cdot 10^{111}:\\
\;\;\;\;-\frac{\frac{z}{\left|\sqrt[3]{3}\right|}}{\sqrt{\sqrt[3]{3}}}\\
\mathbf{elif}\;z \le 4.17182871699966700452276153071931598076 \cdot 10^{130}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(z, z, \mathsf{fma}\left(x, x, y \cdot y\right)\right)} \cdot \sqrt{\frac{1}{3}}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\sqrt{3}}\\
\end{array}double f(double x, double y, double z) {
double r561379 = x;
double r561380 = r561379 * r561379;
double r561381 = y;
double r561382 = r561381 * r561381;
double r561383 = r561380 + r561382;
double r561384 = z;
double r561385 = r561384 * r561384;
double r561386 = r561383 + r561385;
double r561387 = 3.0;
double r561388 = r561386 / r561387;
double r561389 = sqrt(r561388);
return r561389;
}
double f(double x, double y, double z) {
double r561390 = z;
double r561391 = -3.746938595761261e+111;
bool r561392 = r561390 <= r561391;
double r561393 = 3.0;
double r561394 = cbrt(r561393);
double r561395 = fabs(r561394);
double r561396 = r561390 / r561395;
double r561397 = sqrt(r561394);
double r561398 = r561396 / r561397;
double r561399 = -r561398;
double r561400 = 4.171828716999667e+130;
bool r561401 = r561390 <= r561400;
double r561402 = x;
double r561403 = y;
double r561404 = r561403 * r561403;
double r561405 = fma(r561402, r561402, r561404);
double r561406 = fma(r561390, r561390, r561405);
double r561407 = sqrt(r561406);
double r561408 = 1.0;
double r561409 = r561408 / r561393;
double r561410 = sqrt(r561409);
double r561411 = r561407 * r561410;
double r561412 = sqrt(r561393);
double r561413 = r561390 / r561412;
double r561414 = r561401 ? r561411 : r561413;
double r561415 = r561392 ? r561399 : r561414;
return r561415;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 38.1 |
|---|---|
| Target | 25.6 |
| Herbie | 25.6 |
if z < -3.746938595761261e+111Initial program 56.5
Simplified56.5
rmApplied add-sqr-sqrt56.5
Applied add-sqr-sqrt56.5
Applied times-frac56.5
Taylor expanded around -inf 18.0
Simplified18.0
rmApplied add-cube-cbrt18.0
Applied sqrt-prod18.0
Applied associate-/r*18.0
Simplified18.0
if -3.746938595761261e+111 < z < 4.171828716999667e+130Initial program 29.4
Simplified29.4
rmApplied div-inv29.4
Applied sqrt-prod29.5
if 4.171828716999667e+130 < z Initial program 59.0
Simplified59.0
rmApplied add-sqr-sqrt59.0
Applied add-sqr-sqrt59.0
Applied times-frac59.0
Taylor expanded around inf 15.8
Final simplification25.6
herbie shell --seed 2019323 +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.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)))