\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;x \le -4.839580010133738883814333111888121327705 \cdot 10^{89}:\\
\;\;\;\;\left|-\frac{x}{\sqrt{3}}\right|\\
\mathbf{elif}\;x \le -1.300826073826069390206779020116460497933 \cdot 10^{-184}:\\
\;\;\;\;\left|\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{\sqrt{3}}\right|\\
\mathbf{elif}\;x \le 2.963930732093339184027916604821132221056 \cdot 10^{-286}:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;x \le 4.808010570528259607557562930705767404361 \cdot 10^{-173}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \cdot \sqrt{\frac{1}{3}}\\
\mathbf{elif}\;x \le 3.157422220345378975630750006632647108073 \cdot 10^{-141}:\\
\;\;\;\;\left|\frac{z}{\sqrt{3}}\right|\\
\mathbf{elif}\;x \le 1.681133737755100120774954244284973127491 \cdot 10^{93}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \cdot \sqrt{\frac{1}{3}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \sqrt{0.3333333333333333148296162562473909929395}\\
\end{array}double f(double x, double y, double z) {
double r547511 = x;
double r547512 = r547511 * r547511;
double r547513 = y;
double r547514 = r547513 * r547513;
double r547515 = r547512 + r547514;
double r547516 = z;
double r547517 = r547516 * r547516;
double r547518 = r547515 + r547517;
double r547519 = 3.0;
double r547520 = r547518 / r547519;
double r547521 = sqrt(r547520);
return r547521;
}
double f(double x, double y, double z) {
double r547522 = x;
double r547523 = -4.839580010133739e+89;
bool r547524 = r547522 <= r547523;
double r547525 = 3.0;
double r547526 = sqrt(r547525);
double r547527 = r547522 / r547526;
double r547528 = -r547527;
double r547529 = fabs(r547528);
double r547530 = -1.3008260738260694e-184;
bool r547531 = r547522 <= r547530;
double r547532 = r547522 * r547522;
double r547533 = y;
double r547534 = r547533 * r547533;
double r547535 = r547532 + r547534;
double r547536 = z;
double r547537 = r547536 * r547536;
double r547538 = r547535 + r547537;
double r547539 = sqrt(r547538);
double r547540 = r547539 / r547526;
double r547541 = fabs(r547540);
double r547542 = 2.963930732093339e-286;
bool r547543 = r547522 <= r547542;
double r547544 = r547536 / r547526;
double r547545 = fabs(r547544);
double r547546 = 4.8080105705282596e-173;
bool r547547 = r547522 <= r547546;
double r547548 = 1.0;
double r547549 = r547548 / r547525;
double r547550 = sqrt(r547549);
double r547551 = r547539 * r547550;
double r547552 = 3.157422220345379e-141;
bool r547553 = r547522 <= r547552;
double r547554 = 1.6811337377551001e+93;
bool r547555 = r547522 <= r547554;
double r547556 = 0.3333333333333333;
double r547557 = sqrt(r547556);
double r547558 = r547522 * r547557;
double r547559 = r547555 ? r547551 : r547558;
double r547560 = r547553 ? r547545 : r547559;
double r547561 = r547547 ? r547551 : r547560;
double r547562 = r547543 ? r547545 : r547561;
double r547563 = r547531 ? r547541 : r547562;
double r547564 = r547524 ? r547529 : r547563;
return r547564;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.6 |
|---|---|
| Target | 25.5 |
| Herbie | 25.5 |
if x < -4.839580010133739e+89Initial program 52.1
rmApplied add-sqr-sqrt52.2
Applied add-sqr-sqrt52.2
Applied times-frac52.2
Applied rem-sqrt-square52.2
Taylor expanded around -inf 19.7
Simplified19.7
if -4.839580010133739e+89 < x < -1.3008260738260694e-184Initial program 27.0
rmApplied add-sqr-sqrt27.1
Applied add-sqr-sqrt27.1
Applied times-frac27.1
Applied rem-sqrt-square27.1
if -1.3008260738260694e-184 < x < 2.963930732093339e-286 or 4.8080105705282596e-173 < x < 3.157422220345379e-141Initial program 32.5
rmApplied add-sqr-sqrt32.6
Applied add-sqr-sqrt32.6
Applied times-frac32.6
Applied rem-sqrt-square32.6
Taylor expanded around 0 31.2
if 2.963930732093339e-286 < x < 4.8080105705282596e-173 or 3.157422220345379e-141 < x < 1.6811337377551001e+93Initial program 29.1
rmApplied div-inv29.1
Applied sqrt-prod29.2
if 1.6811337377551001e+93 < x Initial program 54.1
Taylor expanded around inf 18.6
Final simplification25.5
herbie shell --seed 2019326
(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)))