Average Error: 37.7 → 0.3
Time: 4.4s
Precision: 64
\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
\[\frac{\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\left|\sqrt[3]{3}\right|}}{\sqrt{\sqrt[3]{3}}}\]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\frac{\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\left|\sqrt[3]{3}\right|}}{\sqrt{\sqrt[3]{3}}}
double code(double x, double y, double z) {
	return ((double) sqrt(((double) (((double) (((double) (((double) (x * x)) + ((double) (y * y)))) + ((double) (z * z)))) / 3.0))));
}
double code(double x, double y, double z) {
	return ((double) (((double) (((double) hypot(((double) hypot(x, y)), z)) / ((double) fabs(((double) cbrt(3.0)))))) / ((double) sqrt(((double) cbrt(3.0))))));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original37.7
Target25.3
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;z \lt -6.3964793941097758 \cdot 10^{136}:\\ \;\;\;\;\frac{-z}{\sqrt{3}}\\ \mathbf{elif}\;z \lt 7.3202936944041821 \cdot 10^{117}:\\ \;\;\;\;\frac{\sqrt{\left(z \cdot z + x \cdot x\right) + y \cdot y}}{\sqrt{3}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.333333333333333315} \cdot z\\ \end{array}\]

Derivation

  1. Initial program 37.7

    \[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
  2. Using strategy rm
  3. Applied sqrt-div37.7

    \[\leadsto \color{blue}{\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{\sqrt{3}}}\]
  4. Using strategy rm
  5. Applied add-sqr-sqrt37.7

    \[\leadsto \frac{\sqrt{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}} + z \cdot z}}{\sqrt{3}}\]
  6. Applied hypot-def28.4

    \[\leadsto \frac{\color{blue}{\mathsf{hypot}\left(\sqrt{x \cdot x + y \cdot y}, z\right)}}{\sqrt{3}}\]
  7. Using strategy rm
  8. Applied hypot-def0.4

    \[\leadsto \frac{\mathsf{hypot}\left(\color{blue}{\mathsf{hypot}\left(x, y\right)}, z\right)}{\sqrt{3}}\]
  9. Using strategy rm
  10. Applied add-cube-cbrt0.4

    \[\leadsto \frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\sqrt{\color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}}\]
  11. Applied sqrt-prod0.4

    \[\leadsto \frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\color{blue}{\sqrt{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \sqrt{\sqrt[3]{3}}}}\]
  12. Applied associate-/r*0.3

    \[\leadsto \color{blue}{\frac{\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\sqrt{\sqrt[3]{3} \cdot \sqrt[3]{3}}}}{\sqrt{\sqrt[3]{3}}}}\]
  13. Simplified0.3

    \[\leadsto \frac{\color{blue}{\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\left|\sqrt[3]{3}\right|}}}{\sqrt{\sqrt[3]{3}}}\]
  14. Final simplification0.3

    \[\leadsto \frac{\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\left|\sqrt[3]{3}\right|}}{\sqrt{\sqrt[3]{3}}}\]

Reproduce

herbie shell --seed 2020122 +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)))