\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\begin{array}{l}
\mathbf{if}\;z \leq 8.300356615998216 \cdot 10^{-137}:\\
\;\;\;\;-\sqrt{\sqrt{\sqrt[3]{0.3333333333333333} \cdot \sqrt[3]{0.3333333333333333}}} \cdot \left(\sqrt{\sqrt{\sqrt[3]{0.3333333333333333}}} \cdot \left(x \cdot \sqrt{\sqrt{0.3333333333333333}}\right)\right)\\
\mathbf{elif}\;z \leq 1.9929948001661953 \cdot 10^{+32}:\\
\;\;\;\;\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\
\mathbf{elif}\;z \leq 1.5389623186968813 \cdot 10^{+44}:\\
\;\;\;\;-\sqrt{\sqrt{0.3333333333333333}} \cdot \left(x \cdot \sqrt{\sqrt{0.3333333333333333}}\right)\\
\mathbf{elif}\;z \leq 1.9982784290001902 \cdot 10^{+146}:\\
\;\;\;\;\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \sqrt{0.3333333333333333}\\
\end{array}(FPCore (x y z) :precision binary64 (sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))
(FPCore (x y z)
:precision binary64
(if (<= z 8.300356615998216e-137)
(-
(*
(sqrt (sqrt (* (cbrt 0.3333333333333333) (cbrt 0.3333333333333333))))
(*
(sqrt (sqrt (cbrt 0.3333333333333333)))
(* x (sqrt (sqrt 0.3333333333333333))))))
(if (<= z 1.9929948001661953e+32)
(sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0))
(if (<= z 1.5389623186968813e+44)
(-
(*
(sqrt (sqrt 0.3333333333333333))
(* x (sqrt (sqrt 0.3333333333333333)))))
(if (<= z 1.9982784290001902e+146)
(sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0))
(* z (sqrt 0.3333333333333333)))))))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 tmp;
if (z <= 8.300356615998216e-137) {
tmp = -(sqrt(sqrt(cbrt(0.3333333333333333) * cbrt(0.3333333333333333))) * (sqrt(sqrt(cbrt(0.3333333333333333))) * (x * sqrt(sqrt(0.3333333333333333)))));
} else if (z <= 1.9929948001661953e+32) {
tmp = sqrt((((x * x) + (y * y)) + (z * z)) / 3.0);
} else if (z <= 1.5389623186968813e+44) {
tmp = -(sqrt(sqrt(0.3333333333333333)) * (x * sqrt(sqrt(0.3333333333333333))));
} else if (z <= 1.9982784290001902e+146) {
tmp = sqrt((((x * x) + (y * y)) + (z * z)) / 3.0);
} else {
tmp = z * sqrt(0.3333333333333333);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 38.3 |
|---|---|
| Target | 19.9 |
| Herbie | 11.8 |
if z < 8.3003566159982158e-137Initial program 35.3
Taylor expanded around -inf 3.7
Simplified3.7
rmApplied add-sqr-sqrt_binary64_215833.7
Applied associate-*l*_binary64_215023.6
Simplified3.6
rmApplied add-cube-cbrt_binary64_215963.6
Applied sqrt-prod_binary64_215773.6
Applied sqrt-prod_binary64_215773.6
Applied associate-*l*_binary64_215023.6
if 8.3003566159982158e-137 < z < 1.99299480016619532e32 or 1.5389623186968813e44 < z < 1.9982784290001902e146Initial program 19.4
if 1.99299480016619532e32 < z < 1.5389623186968813e44Initial program 20.2
Taylor expanded around -inf 31.6
Simplified31.6
rmApplied add-sqr-sqrt_binary64_2158331.6
Applied associate-*l*_binary64_2150231.6
Simplified31.6
if 1.9982784290001902e146 < z Initial program 62.1
Taylor expanded around inf 8.6
Final simplification11.8
herbie shell --seed 2021093
(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.0)) (if (< z 7.320293694404182e+117) (/ (sqrt (+ (+ (* z z) (* x x)) (* y y))) (sqrt 3.0)) (* (sqrt 0.3333333333333333) z)))
(sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))