Average Error: 38.1 → 0.3
Time: 7.0s
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(\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(\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 r801314 = x;
        double r801315 = r801314 * r801314;
        double r801316 = y;
        double r801317 = r801316 * r801316;
        double r801318 = r801315 + r801317;
        double r801319 = z;
        double r801320 = r801319 * r801319;
        double r801321 = r801318 + r801320;
        double r801322 = 3.0;
        double r801323 = r801321 / r801322;
        double r801324 = sqrt(r801323);
        return r801324;
}

double f(double x, double y, double z) {
        double r801325 = 1.0;
        double r801326 = 3.0;
        double r801327 = cbrt(r801326);
        double r801328 = r801327 * r801327;
        double r801329 = r801325 / r801328;
        double r801330 = sqrt(r801329);
        double r801331 = x;
        double r801332 = y;
        double r801333 = hypot(r801331, r801332);
        double r801334 = z;
        double r801335 = hypot(r801333, r801334);
        double r801336 = r801330 * r801335;
        double r801337 = r801325 / r801327;
        double r801338 = sqrt(r801337);
        double r801339 = r801336 * r801338;
        return r801339;
}

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 hypot-def0.3

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

    \[\leadsto \left(\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \mathsf{hypot}\left(\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)))