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(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 r776027 = x;
        double r776028 = r776027 * r776027;
        double r776029 = y;
        double r776030 = r776029 * r776029;
        double r776031 = r776028 + r776030;
        double r776032 = z;
        double r776033 = r776032 * r776032;
        double r776034 = r776031 + r776033;
        double r776035 = 3.0;
        double r776036 = r776034 / r776035;
        double r776037 = sqrt(r776036);
        return r776037;
}

double f(double x, double y, double z) {
        double r776038 = 1.0;
        double r776039 = 3.0;
        double r776040 = cbrt(r776039);
        double r776041 = r776040 * r776040;
        double r776042 = r776038 / r776041;
        double r776043 = sqrt(r776042);
        double r776044 = x;
        double r776045 = y;
        double r776046 = hypot(r776044, r776045);
        double r776047 = r776038 * r776046;
        double r776048 = z;
        double r776049 = hypot(r776047, r776048);
        double r776050 = r776043 * r776049;
        double r776051 = r776038 / r776040;
        double r776052 = sqrt(r776051);
        double r776053 = r776050 * r776052;
        return r776053;
}

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)))