\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 3.7682365661707411 \cdot 10^{-288}:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;x \cdot x + y \cdot y \le 6.36921913743591853 \cdot 10^{78}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \cdot \sqrt{\frac{1}{3}}\\
\mathbf{elif}\;x \cdot x + y \cdot y \le 9.21234681244353091 \cdot 10^{127}:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;x \cdot x + y \cdot y \le 7.3089500670956082 \cdot 10^{304}:\\
\;\;\;\;\left|\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{\sqrt{3}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|-1 \cdot \left(\frac{1}{\sqrt[3]{\sqrt{3}} \cdot \sqrt[3]{\sqrt{3}}} \cdot \frac{x}{\sqrt[3]{\sqrt{3}}}\right)\right|\\
\end{array}double f(double x, double y, double z) {
double r840417 = x;
double r840418 = r840417 * r840417;
double r840419 = y;
double r840420 = r840419 * r840419;
double r840421 = r840418 + r840420;
double r840422 = z;
double r840423 = r840422 * r840422;
double r840424 = r840421 + r840423;
double r840425 = 3.0;
double r840426 = r840424 / r840425;
double r840427 = sqrt(r840426);
return r840427;
}
double f(double x, double y, double z) {
double r840428 = x;
double r840429 = r840428 * r840428;
double r840430 = y;
double r840431 = r840430 * r840430;
double r840432 = r840429 + r840431;
double r840433 = 3.768236566170741e-288;
bool r840434 = r840432 <= r840433;
double r840435 = z;
double r840436 = 3.0;
double r840437 = sqrt(r840436);
double r840438 = r840435 / r840437;
double r840439 = fabs(r840438);
double r840440 = 6.3692191374359185e+78;
bool r840441 = r840432 <= r840440;
double r840442 = r840435 * r840435;
double r840443 = r840432 + r840442;
double r840444 = sqrt(r840443);
double r840445 = 1.0;
double r840446 = r840445 / r840436;
double r840447 = sqrt(r840446);
double r840448 = r840444 * r840447;
double r840449 = 9.21234681244353e+127;
bool r840450 = r840432 <= r840449;
double r840451 = 7.308950067095608e+304;
bool r840452 = r840432 <= r840451;
double r840453 = r840444 / r840437;
double r840454 = fabs(r840453);
double r840455 = -1.0;
double r840456 = cbrt(r840437);
double r840457 = r840456 * r840456;
double r840458 = r840445 / r840457;
double r840459 = r840428 / r840456;
double r840460 = r840458 * r840459;
double r840461 = r840455 * r840460;
double r840462 = fabs(r840461);
double r840463 = r840452 ? r840454 : r840462;
double r840464 = r840450 ? r840439 : r840463;
double r840465 = r840441 ? r840448 : r840464;
double r840466 = r840434 ? r840439 : r840465;
return r840466;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.2 |
|---|---|
| Target | 26.1 |
| Herbie | 24.4 |
if (+ (* x x) (* y y)) < 3.768236566170741e-288 or 6.3692191374359185e+78 < (+ (* x x) (* y y)) < 9.21234681244353e+127Initial program 23.9
rmApplied add-sqr-sqrt24.1
Applied add-sqr-sqrt24.1
Applied times-frac24.0
Applied rem-sqrt-square24.0
Taylor expanded around 0 19.1
if 3.768236566170741e-288 < (+ (* x x) (* y y)) < 6.3692191374359185e+78Initial program 15.7
rmApplied div-inv15.7
Applied sqrt-prod15.9
if 9.21234681244353e+127 < (+ (* x x) (* y y)) < 7.308950067095608e+304Initial program 15.6
rmApplied add-sqr-sqrt15.9
Applied add-sqr-sqrt15.9
Applied times-frac15.8
Applied rem-sqrt-square15.8
if 7.308950067095608e+304 < (+ (* x x) (* y y)) Initial program 63.6
rmApplied add-sqr-sqrt63.6
Applied add-sqr-sqrt63.6
Applied times-frac63.6
Applied rem-sqrt-square63.6
Taylor expanded around -inf 33.9
rmApplied add-cube-cbrt33.9
Applied *-un-lft-identity33.9
Applied times-frac34.0
Final simplification24.4
herbie shell --seed 2020047
(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)))