\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\left|\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\sqrt{3}}\right|double f(double x, double y, double z) {
double r1033387 = x;
double r1033388 = r1033387 * r1033387;
double r1033389 = y;
double r1033390 = r1033389 * r1033389;
double r1033391 = r1033388 + r1033390;
double r1033392 = z;
double r1033393 = r1033392 * r1033392;
double r1033394 = r1033391 + r1033393;
double r1033395 = 3.0;
double r1033396 = r1033394 / r1033395;
double r1033397 = sqrt(r1033396);
return r1033397;
}
double f(double x, double y, double z) {
double r1033398 = x;
double r1033399 = y;
double r1033400 = hypot(r1033398, r1033399);
double r1033401 = z;
double r1033402 = hypot(r1033400, r1033401);
double r1033403 = 3.0;
double r1033404 = sqrt(r1033403);
double r1033405 = r1033402 / r1033404;
double r1033406 = fabs(r1033405);
return r1033406;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.8 |
|---|---|
| Target | 25.5 |
| Herbie | 0.4 |
Initial program 37.8
rmApplied add-sqr-sqrt38.0
Applied add-sqr-sqrt38.0
Applied times-frac37.9
Applied rem-sqrt-square37.9
rmApplied add-sqr-sqrt37.9
Applied hypot-def28.6
rmApplied hypot-def0.4
Final simplification0.4
herbie shell --seed 2020060 +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)))