\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;x \cdot x + y \cdot y \le 9.5571349373151974 \cdot 10^{307}:\\
\;\;\;\;\left|\frac{\mathsf{hypot}\left(\sqrt{x \cdot x + y \cdot y}, z\right)}{\sqrt{3}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\sqrt{3}}\right|\\
\end{array}double f(double x, double y, double z) {
double r925276 = x;
double r925277 = r925276 * r925276;
double r925278 = y;
double r925279 = r925278 * r925278;
double r925280 = r925277 + r925279;
double r925281 = z;
double r925282 = r925281 * r925281;
double r925283 = r925280 + r925282;
double r925284 = 3.0;
double r925285 = r925283 / r925284;
double r925286 = sqrt(r925285);
return r925286;
}
double f(double x, double y, double z) {
double r925287 = x;
double r925288 = r925287 * r925287;
double r925289 = y;
double r925290 = r925289 * r925289;
double r925291 = r925288 + r925290;
double r925292 = 9.557134937315197e+307;
bool r925293 = r925291 <= r925292;
double r925294 = sqrt(r925291);
double r925295 = z;
double r925296 = hypot(r925294, r925295);
double r925297 = 3.0;
double r925298 = sqrt(r925297);
double r925299 = r925296 / r925298;
double r925300 = fabs(r925299);
double r925301 = r925287 / r925298;
double r925302 = fabs(r925301);
double r925303 = r925293 ? r925300 : r925302;
return r925303;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.7 |
|---|---|
| Target | 25.8 |
| Herbie | 15.7 |
if (+ (* x x) (* y y)) < 9.557134937315197e+307Initial program 17.1
rmApplied add-sqr-sqrt17.3
Applied add-sqr-sqrt17.3
Applied times-frac17.3
Applied rem-sqrt-square17.3
rmApplied add-sqr-sqrt17.3
Applied hypot-def1.4
if 9.557134937315197e+307 < (+ (* x x) (* y y)) Initial program 64.0
rmApplied add-sqr-sqrt64.0
Applied add-sqr-sqrt64.0
Applied times-frac64.0
Applied rem-sqrt-square64.0
Taylor expanded around inf 34.0
Final simplification15.7
herbie shell --seed 2020045 +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)))