\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;z \le -1.919949817214073938734336094914511930365 \cdot 10^{152}:\\
\;\;\;\;-z \cdot \sqrt{0.3333333333333333148296162562473909929395}\\
\mathbf{elif}\;z \le 3.216933802137221684316757518669772199128 \cdot 10^{-308}:\\
\;\;\;\;\sqrt{\frac{\mathsf{fma}\left(z, z, \mathsf{fma}\left(x, x, y \cdot y\right)\right)}{3}}\\
\mathbf{elif}\;z \le 1.082662187591500004465358532585611193411 \cdot 10^{-284}:\\
\;\;\;\;y \cdot \sqrt{0.3333333333333333148296162562473909929395}\\
\mathbf{elif}\;z \le 2.70108591667212070105861187564907986718 \cdot 10^{121}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(z, z, \mathsf{fma}\left(x, x, y \cdot y\right)\right)}}{\sqrt{3}}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\sqrt{3}}\\
\end{array}double f(double x, double y, double z) {
double r396556 = x;
double r396557 = r396556 * r396556;
double r396558 = y;
double r396559 = r396558 * r396558;
double r396560 = r396557 + r396559;
double r396561 = z;
double r396562 = r396561 * r396561;
double r396563 = r396560 + r396562;
double r396564 = 3.0;
double r396565 = r396563 / r396564;
double r396566 = sqrt(r396565);
return r396566;
}
double f(double x, double y, double z) {
double r396567 = z;
double r396568 = -1.919949817214074e+152;
bool r396569 = r396567 <= r396568;
double r396570 = 0.3333333333333333;
double r396571 = sqrt(r396570);
double r396572 = r396567 * r396571;
double r396573 = -r396572;
double r396574 = 3.2169338021372217e-308;
bool r396575 = r396567 <= r396574;
double r396576 = x;
double r396577 = y;
double r396578 = r396577 * r396577;
double r396579 = fma(r396576, r396576, r396578);
double r396580 = fma(r396567, r396567, r396579);
double r396581 = 3.0;
double r396582 = r396580 / r396581;
double r396583 = sqrt(r396582);
double r396584 = 1.0826621875915e-284;
bool r396585 = r396567 <= r396584;
double r396586 = r396577 * r396571;
double r396587 = 2.7010859166721207e+121;
bool r396588 = r396567 <= r396587;
double r396589 = sqrt(r396580);
double r396590 = sqrt(r396581);
double r396591 = r396589 / r396590;
double r396592 = r396567 / r396590;
double r396593 = r396588 ? r396591 : r396592;
double r396594 = r396585 ? r396586 : r396593;
double r396595 = r396575 ? r396583 : r396594;
double r396596 = r396569 ? r396573 : r396595;
return r396596;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 37.8 |
|---|---|
| Target | 25.7 |
| Herbie | 25.9 |
if z < -1.919949817214074e+152Initial program 63.7
Simplified63.7
rmApplied div-inv63.7
Applied sqrt-prod63.7
rmApplied add-exp-log63.7
Applied add-exp-log63.7
Applied prod-exp63.7
Simplified63.7
Taylor expanded around -inf 17.2
Simplified17.2
if -1.919949817214074e+152 < z < 3.2169338021372217e-308Initial program 29.1
Simplified29.1
if 3.2169338021372217e-308 < z < 1.0826621875915e-284Initial program 32.7
Simplified32.7
Taylor expanded around 0 48.1
if 1.0826621875915e-284 < z < 2.7010859166721207e+121Initial program 28.8
Simplified28.8
rmApplied sqrt-div28.9
if 2.7010859166721207e+121 < z Initial program 57.9
Simplified57.9
rmApplied sqrt-div57.9
Taylor expanded around inf 16.3
Final simplification25.9
herbie shell --seed 2019306 +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)))