\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;y \le -4.636290233423019225578992902970977131599 \cdot 10^{86}:\\
\;\;\;\;\sqrt{0.3333333333333333148296162562473909929395} \cdot \left(-y\right)\\
\mathbf{elif}\;y \le -6.50065769373261489118803575957100157732 \cdot 10^{70}:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;y \le -1.595389421696917498221625505629493011546 \cdot 10^{-66}:\\
\;\;\;\;\sqrt{\frac{1}{3} \cdot \mathsf{fma}\left(y, y, \mathsf{fma}\left(z, z, x \cdot x\right)\right)}\\
\mathbf{elif}\;y \le 3.473733918617740311509637678395980100535 \cdot 10^{-147}:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;y \le 9.09880737550489603575935437091842714316 \cdot 10^{60}:\\
\;\;\;\;\sqrt{\frac{\sqrt{\mathsf{fma}\left(y, y, \mathsf{fma}\left(z, z, x \cdot x\right)\right)}}{3} \cdot \sqrt{\mathsf{fma}\left(y, y, \mathsf{fma}\left(z, z, x \cdot x\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.3333333333333333148296162562473909929395} \cdot y\\
\end{array}double f(double x, double y, double z) {
double r631355 = x;
double r631356 = r631355 * r631355;
double r631357 = y;
double r631358 = r631357 * r631357;
double r631359 = r631356 + r631358;
double r631360 = z;
double r631361 = r631360 * r631360;
double r631362 = r631359 + r631361;
double r631363 = 3.0;
double r631364 = r631362 / r631363;
double r631365 = sqrt(r631364);
return r631365;
}
double f(double x, double y, double z) {
double r631366 = y;
double r631367 = -4.636290233423019e+86;
bool r631368 = r631366 <= r631367;
double r631369 = 0.3333333333333333;
double r631370 = sqrt(r631369);
double r631371 = -r631366;
double r631372 = r631370 * r631371;
double r631373 = -6.500657693732615e+70;
bool r631374 = r631366 <= r631373;
double r631375 = z;
double r631376 = 3.0;
double r631377 = sqrt(r631376);
double r631378 = r631375 / r631377;
double r631379 = fabs(r631378);
double r631380 = -1.5953894216969175e-66;
bool r631381 = r631366 <= r631380;
double r631382 = 1.0;
double r631383 = r631382 / r631376;
double r631384 = x;
double r631385 = r631384 * r631384;
double r631386 = fma(r631375, r631375, r631385);
double r631387 = fma(r631366, r631366, r631386);
double r631388 = r631383 * r631387;
double r631389 = sqrt(r631388);
double r631390 = 3.4737339186177403e-147;
bool r631391 = r631366 <= r631390;
double r631392 = 9.098807375504896e+60;
bool r631393 = r631366 <= r631392;
double r631394 = sqrt(r631387);
double r631395 = r631394 / r631376;
double r631396 = r631395 * r631394;
double r631397 = sqrt(r631396);
double r631398 = r631370 * r631366;
double r631399 = r631393 ? r631397 : r631398;
double r631400 = r631391 ? r631379 : r631399;
double r631401 = r631381 ? r631389 : r631400;
double r631402 = r631374 ? r631379 : r631401;
double r631403 = r631368 ? r631372 : r631402;
return r631403;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 37.2 |
|---|---|
| Target | 25.0 |
| Herbie | 26.2 |
if y < -4.636290233423019e+86Initial program 52.8
Simplified52.8
Taylor expanded around -inf 18.1
Simplified18.1
if -4.636290233423019e+86 < y < -6.500657693732615e+70 or -1.5953894216969175e-66 < y < 3.4737339186177403e-147Initial program 29.9
Simplified29.9
rmApplied add-sqr-sqrt30.0
Applied add-sqr-sqrt30.0
Applied times-frac30.0
Applied rem-sqrt-square30.0
Taylor expanded around 0 32.4
if -6.500657693732615e+70 < y < -1.5953894216969175e-66Initial program 25.5
Simplified25.5
rmApplied *-un-lft-identity25.5
Applied add-sqr-sqrt25.5
Applied times-frac25.5
Simplified25.5
Simplified25.5
rmApplied div-inv25.6
Applied associate-*r*25.6
Simplified25.6
if 3.4737339186177403e-147 < y < 9.098807375504896e+60Initial program 28.4
Simplified28.4
rmApplied *-un-lft-identity28.4
Applied add-sqr-sqrt28.4
Applied times-frac28.4
Simplified28.4
Simplified28.4
if 9.098807375504896e+60 < y Initial program 50.0
Simplified50.0
rmApplied *-un-lft-identity50.0
Applied add-sqr-sqrt50.0
Applied times-frac50.0
Simplified50.0
Simplified50.0
Taylor expanded around inf 21.3
Simplified21.3
Final simplification26.2
herbie shell --seed 2019179 +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)))