Average Error: 38.1 → 0.3
Time: 7.2s
Precision: 64
\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
\[\left(\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \mathsf{hypot}\left(1 \cdot \mathsf{hypot}\left(x, y\right), z\right)\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\left(\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \mathsf{hypot}\left(1 \cdot \mathsf{hypot}\left(x, y\right), z\right)\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}
double f(double x, double y, double z) {
        double r837171 = x;
        double r837172 = r837171 * r837171;
        double r837173 = y;
        double r837174 = r837173 * r837173;
        double r837175 = r837172 + r837174;
        double r837176 = z;
        double r837177 = r837176 * r837176;
        double r837178 = r837175 + r837177;
        double r837179 = 3.0;
        double r837180 = r837178 / r837179;
        double r837181 = sqrt(r837180);
        return r837181;
}

double f(double x, double y, double z) {
        double r837182 = 1.0;
        double r837183 = 3.0;
        double r837184 = cbrt(r837183);
        double r837185 = r837184 * r837184;
        double r837186 = r837182 / r837185;
        double r837187 = sqrt(r837186);
        double r837188 = x;
        double r837189 = y;
        double r837190 = hypot(r837188, r837189);
        double r837191 = r837182 * r837190;
        double r837192 = z;
        double r837193 = hypot(r837191, r837192);
        double r837194 = r837187 * r837193;
        double r837195 = r837182 / r837184;
        double r837196 = sqrt(r837195);
        double r837197 = r837194 * r837196;
        return r837197;
}

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

Original38.1
Target26.0
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;z \lt -6.396479394109775845820908799933348003545 \cdot 10^{136}:\\ \;\;\;\;\frac{-z}{\sqrt{3}}\\ \mathbf{elif}\;z \lt 7.320293694404182125923160810847974073098 \cdot 10^{117}:\\ \;\;\;\;\frac{\sqrt{\left(z \cdot z + x \cdot x\right) + y \cdot y}}{\sqrt{3}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.3333333333333333148296162562473909929395} \cdot z\\ \end{array}\]

Derivation

  1. Initial program 38.1

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

    \[\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 *-un-lft-identity38.1

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

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

    \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{\sqrt[3]{3}}}}\]
  7. Using strategy rm
  8. Applied div-inv38.1

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

    \[\leadsto \sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \color{blue}{\left(\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\right)}\]
  10. Applied associate-*r*38.1

    \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}}\]
  11. Using strategy rm
  12. Applied add-sqr-sqrt38.1

    \[\leadsto \left(\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \sqrt{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}} + z \cdot z}\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\]
  13. Applied hypot-def29.0

    \[\leadsto \left(\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \color{blue}{\mathsf{hypot}\left(\sqrt{x \cdot x + y \cdot y}, z\right)}\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\]
  14. Using strategy rm
  15. Applied *-un-lft-identity29.0

    \[\leadsto \left(\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \mathsf{hypot}\left(\sqrt{\color{blue}{1 \cdot \left(x \cdot x + y \cdot y\right)}}, z\right)\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\]
  16. Applied sqrt-prod29.0

    \[\leadsto \left(\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \mathsf{hypot}\left(\color{blue}{\sqrt{1} \cdot \sqrt{x \cdot x + y \cdot y}}, z\right)\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\]
  17. Simplified29.0

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

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

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

Reproduce

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