Average Error: 37.7 → 25.5
Time: 44.4s
Precision: 64
\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.114597052343943905521456364925785524812 \cdot 10^{96}:\\ \;\;\;\;\sqrt{\sqrt{0.3333333333333333148296162562473909929395}} \cdot \left(-\sqrt{\sqrt{0.3333333333333333148296162562473909929395}} \cdot x\right)\\ \mathbf{elif}\;x \le 9.445373192608023995102518569819932542768 \cdot 10^{93}:\\ \;\;\;\;\sqrt{\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}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.3333333333333333148296162562473909929395} \cdot x\\ \end{array}\]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\begin{array}{l}
\mathbf{if}\;x \le -2.114597052343943905521456364925785524812 \cdot 10^{96}:\\
\;\;\;\;\sqrt{\sqrt{0.3333333333333333148296162562473909929395}} \cdot \left(-\sqrt{\sqrt{0.3333333333333333148296162562473909929395}} \cdot x\right)\\

\mathbf{elif}\;x \le 9.445373192608023995102518569819932542768 \cdot 10^{93}:\\
\;\;\;\;\sqrt{\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}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{0.3333333333333333148296162562473909929395} \cdot x\\

\end{array}
double f(double x, double y, double z) {
        double r37366921 = x;
        double r37366922 = r37366921 * r37366921;
        double r37366923 = y;
        double r37366924 = r37366923 * r37366923;
        double r37366925 = r37366922 + r37366924;
        double r37366926 = z;
        double r37366927 = r37366926 * r37366926;
        double r37366928 = r37366925 + r37366927;
        double r37366929 = 3.0;
        double r37366930 = r37366928 / r37366929;
        double r37366931 = sqrt(r37366930);
        return r37366931;
}

double f(double x, double y, double z) {
        double r37366932 = x;
        double r37366933 = -2.114597052343944e+96;
        bool r37366934 = r37366932 <= r37366933;
        double r37366935 = 0.3333333333333333;
        double r37366936 = sqrt(r37366935);
        double r37366937 = sqrt(r37366936);
        double r37366938 = r37366937 * r37366932;
        double r37366939 = -r37366938;
        double r37366940 = r37366937 * r37366939;
        double r37366941 = 9.445373192608024e+93;
        bool r37366942 = r37366932 <= r37366941;
        double r37366943 = r37366932 * r37366932;
        double r37366944 = y;
        double r37366945 = r37366944 * r37366944;
        double r37366946 = r37366943 + r37366945;
        double r37366947 = z;
        double r37366948 = r37366947 * r37366947;
        double r37366949 = r37366946 + r37366948;
        double r37366950 = sqrt(r37366949);
        double r37366951 = 3.0;
        double r37366952 = cbrt(r37366951);
        double r37366953 = r37366952 * r37366952;
        double r37366954 = r37366950 / r37366953;
        double r37366955 = r37366950 / r37366952;
        double r37366956 = r37366954 * r37366955;
        double r37366957 = sqrt(r37366956);
        double r37366958 = r37366936 * r37366932;
        double r37366959 = r37366942 ? r37366957 : r37366958;
        double r37366960 = r37366934 ? r37366940 : r37366959;
        return r37366960;
}

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
Target26.0
Herbie25.5
\[\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. Split input into 3 regimes
  2. if x < -2.114597052343944e+96

    1. Initial program 54.0

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

      \[\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-sqrt54.0

      \[\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-frac54.0

      \[\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. Taylor expanded around -inf 18.1

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \sqrt{0.3333333333333333148296162562473909929395}\right)}\]
    7. Simplified18.1

      \[\leadsto \color{blue}{-\sqrt{0.3333333333333333148296162562473909929395} \cdot x}\]
    8. Using strategy rm
    9. Applied add-sqr-sqrt18.1

      \[\leadsto -\sqrt{\color{blue}{\sqrt{0.3333333333333333148296162562473909929395} \cdot \sqrt{0.3333333333333333148296162562473909929395}}} \cdot x\]
    10. Applied sqrt-prod18.1

      \[\leadsto -\color{blue}{\left(\sqrt{\sqrt{0.3333333333333333148296162562473909929395}} \cdot \sqrt{\sqrt{0.3333333333333333148296162562473909929395}}\right)} \cdot x\]
    11. Applied associate-*l*18.0

      \[\leadsto -\color{blue}{\sqrt{\sqrt{0.3333333333333333148296162562473909929395}} \cdot \left(\sqrt{\sqrt{0.3333333333333333148296162562473909929395}} \cdot x\right)}\]

    if -2.114597052343944e+96 < x < 9.445373192608024e+93

    1. Initial program 29.3

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

      \[\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-sqrt29.3

      \[\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-frac29.3

      \[\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}}}}\]

    if 9.445373192608024e+93 < x

    1. Initial program 53.4

      \[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
    2. Taylor expanded around inf 18.6

      \[\leadsto \color{blue}{x \cdot \sqrt{0.3333333333333333148296162562473909929395}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification25.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.114597052343943905521456364925785524812 \cdot 10^{96}:\\ \;\;\;\;\sqrt{\sqrt{0.3333333333333333148296162562473909929395}} \cdot \left(-\sqrt{\sqrt{0.3333333333333333148296162562473909929395}} \cdot x\right)\\ \mathbf{elif}\;x \le 9.445373192608023995102518569819932542768 \cdot 10^{93}:\\ \;\;\;\;\sqrt{\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}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.3333333333333333148296162562473909929395} \cdot x\\ \end{array}\]

Reproduce

herbie shell --seed 2019200 
(FPCore (x y z)
  :name "Data.Array.Repa.Algorithms.Pixel:doubleRmsOfRGB8 from repa-algorithms-3.4.0.1"

  :herbie-target
  (if (< z -6.396479394109776e+136) (/ (- z) (sqrt 3.0)) (if (< z 7.320293694404182e+117) (/ (sqrt (+ (+ (* z z) (* x x)) (* y y))) (sqrt 3.0)) (* (sqrt 0.3333333333333333) z)))

  (sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))