\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;x \le -2.016424411749676 \cdot 10^{133}:\\
\;\;\;\;-1 \cdot \frac{x}{\sqrt{3}}\\
\mathbf{elif}\;x \le 1.4232710093281964 \cdot 10^{-37}:\\
\;\;\;\;\sqrt{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \cdot \frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{3}}\\
\mathbf{elif}\;x \le 5.4695075101521495 \cdot 10^{42}:\\
\;\;\;\;z \cdot \sqrt{0.333333333333333315}\\
\mathbf{elif}\;x \le 1.199826361110612 \cdot 10^{75}:\\
\;\;\;\;\sqrt{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \cdot \frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{3}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \sqrt{0.333333333333333315}\\
\end{array}double code(double x, double y, double z) {
return sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
}
double code(double x, double y, double z) {
double temp;
if ((x <= -2.016424411749676e+133)) {
temp = (-1.0 * (x / sqrt(3.0)));
} else {
double temp_1;
if ((x <= 1.4232710093281964e-37)) {
temp_1 = sqrt((sqrt((((x * x) + (y * y)) + (z * z))) * (sqrt((((x * x) + (y * y)) + (z * z))) / 3.0)));
} else {
double temp_2;
if ((x <= 5.4695075101521495e+42)) {
temp_2 = (z * sqrt(0.3333333333333333));
} else {
double temp_3;
if ((x <= 1.199826361110612e+75)) {
temp_3 = sqrt((sqrt((((x * x) + (y * y)) + (z * z))) * (sqrt((((x * x) + (y * y)) + (z * z))) / 3.0)));
} else {
temp_3 = (x * sqrt(0.3333333333333333));
}
temp_2 = temp_3;
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.8 |
|---|---|
| Target | 25.7 |
| Herbie | 27.2 |
if x < -2.016424411749676e+133Initial program 59.7
rmApplied add-sqr-sqrt59.7
Applied add-sqr-sqrt59.7
Applied times-frac59.7
Applied sqrt-prod59.7
Taylor expanded around -inf 15.7
if -2.016424411749676e+133 < x < 1.4232710093281964e-37 or 5.4695075101521495e+42 < x < 1.199826361110612e+75Initial program 29.4
rmApplied *-un-lft-identity29.4
Applied add-sqr-sqrt29.4
Applied times-frac29.4
Simplified29.4
if 1.4232710093281964e-37 < x < 5.4695075101521495e+42Initial program 27.8
Taylor expanded around 0 49.8
if 1.199826361110612e+75 < x Initial program 52.4
Taylor expanded around inf 20.3
Final simplification27.2
herbie shell --seed 2020049 +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)))