\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\begin{array}{l}
t_0 := \sqrt{\sqrt{0.3333333333333333}}\\
t_0 \cdot \left(t_0 \cdot \mathsf{hypot}\left(x, z\right)\right)
\end{array}
(FPCore (x y z) :precision binary64 (sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))
(FPCore (x y z) :precision binary64 (let* ((t_0 (sqrt (sqrt 0.3333333333333333)))) (* t_0 (* t_0 (hypot x z)))))
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 t_0 = sqrt(sqrt(0.3333333333333333));
return t_0 * (t_0 * hypot(x, z));
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 37.5 |
|---|---|
| Target | 19.9 |
| Herbie | 0.8 |
Initial program 37.5
Simplified37.5
Taylor expanded in y around 0 37.8
Simplified0.9
Applied add-sqr-sqrt_binary641.2
Applied add-sqr-sqrt_binary641.2
Applied unswap-sqr_binary641.2
Applied swap-sqr_binary641.2
Applied associate-*l*_binary641.1
Simplified0.8
Final simplification0.8
herbie shell --seed 2021215
(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)))