\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;x \le -18637040731758232623605069933264714596350:\\
\;\;\;\;-\frac{x}{\sqrt{3}}\\
\mathbf{elif}\;x \le 4.376373199179285827713056036389642308458 \cdot 10^{91}:\\
\;\;\;\;\sqrt{\frac{1}{3} \cdot \left(\left(x \cdot x + y \cdot y\right) + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \sqrt{0.3333333333333333148296162562473909929395}\\
\end{array}double f(double x, double y, double z) {
double r575263 = x;
double r575264 = r575263 * r575263;
double r575265 = y;
double r575266 = r575265 * r575265;
double r575267 = r575264 + r575266;
double r575268 = z;
double r575269 = r575268 * r575268;
double r575270 = r575267 + r575269;
double r575271 = 3.0;
double r575272 = r575270 / r575271;
double r575273 = sqrt(r575272);
return r575273;
}
double f(double x, double y, double z) {
double r575274 = x;
double r575275 = -1.8637040731758233e+40;
bool r575276 = r575274 <= r575275;
double r575277 = 3.0;
double r575278 = sqrt(r575277);
double r575279 = r575274 / r575278;
double r575280 = -r575279;
double r575281 = 4.376373199179286e+91;
bool r575282 = r575274 <= r575281;
double r575283 = 1.0;
double r575284 = r575283 / r575277;
double r575285 = r575274 * r575274;
double r575286 = y;
double r575287 = r575286 * r575286;
double r575288 = r575285 + r575287;
double r575289 = z;
double r575290 = r575289 * r575289;
double r575291 = r575288 + r575290;
double r575292 = r575284 * r575291;
double r575293 = sqrt(r575292);
double r575294 = 0.3333333333333333;
double r575295 = sqrt(r575294);
double r575296 = r575274 * r575295;
double r575297 = r575282 ? r575293 : r575296;
double r575298 = r575276 ? r575280 : r575297;
return r575298;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.2 |
|---|---|
| Target | 25.7 |
| Herbie | 26.4 |
if x < -1.8637040731758233e+40Initial program 49.0
rmApplied add-sqr-sqrt49.0
Applied associate-/r*49.0
Taylor expanded around -inf 23.5
Simplified23.5
if -1.8637040731758233e+40 < x < 4.376373199179286e+91Initial program 29.7
rmApplied add-sqr-sqrt29.8
Applied associate-/r*29.8
rmApplied *-un-lft-identity29.8
Applied sqrt-prod29.8
Applied add-sqr-sqrt29.8
Applied times-frac29.8
Applied associate-/l*29.8
Simplified29.7
rmApplied div-inv29.7
Applied add-cube-cbrt29.7
Applied *-un-lft-identity29.7
Applied sqrt-prod29.7
Applied times-frac29.7
Applied times-frac29.7
Simplified29.7
Simplified29.7
if 4.376373199179286e+91 < x Initial program 53.4
Taylor expanded around inf 18.9
Final simplification26.4
herbie shell --seed 2019304
(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)))