Average Error: 37.6 → 0.4
Time: 11.5s
Precision: 64
\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
\[\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(y, x\right), z\right)}{\sqrt{\left(-\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(-\sqrt[3]{3}\right)}}\]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(y, x\right), z\right)}{\sqrt{\left(-\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(-\sqrt[3]{3}\right)}}
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) hypot(((double) hypot(y, x)), z)) / ((double) sqrt(((double) (((double) -(((double) (((double) cbrt(3.0)) * ((double) cbrt(3.0)))))) * ((double) -(((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.6
Target25.4
Herbie0.4
\[\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.6

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

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

    \[\leadsto \sqrt{\frac{\color{blue}{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}\]
  5. Applied times-frac37.6

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

    \[\leadsto \sqrt{\frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \color{blue}{\frac{-\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{-\sqrt[3]{3}}}}\]
  8. Applied frac-2neg37.6

    \[\leadsto \sqrt{\color{blue}{\frac{-\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{-\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \frac{-\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{-\sqrt[3]{3}}}\]
  9. Applied frac-times37.6

    \[\leadsto \sqrt{\color{blue}{\frac{\left(-\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\right) \cdot \left(-\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\right)}{\left(-\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(-\sqrt[3]{3}\right)}}}\]
  10. Applied sqrt-div37.7

    \[\leadsto \color{blue}{\frac{\sqrt{\left(-\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\right) \cdot \left(-\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\right)}}{\sqrt{\left(-\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(-\sqrt[3]{3}\right)}}}\]
  11. Simplified37.7

    \[\leadsto \frac{\color{blue}{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}}{\sqrt{\left(-\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(-\sqrt[3]{3}\right)}}\]
  12. Using strategy rm
  13. 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{\left(-\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(-\sqrt[3]{3}\right)}}\]
  14. Applied hypot-def28.2

    \[\leadsto \frac{\color{blue}{\mathsf{hypot}\left(\sqrt{x \cdot x + y \cdot y}, z\right)}}{\sqrt{\left(-\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(-\sqrt[3]{3}\right)}}\]
  15. Using strategy rm
  16. Applied +-commutative28.2

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

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

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

Reproduce

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