Average Error: 37.7 → 25.7
Time: 19.7s
Precision: 64
\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.934591556850648877179646504172286937752 \cdot 10^{139}:\\ \;\;\;\;\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \left(-\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot x\right)\\ \mathbf{elif}\;x \le 1.758065253567775503978920400402254303936 \cdot 10^{99}:\\ \;\;\;\;\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{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \left(\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot x\right)\\ \end{array}\]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\begin{array}{l}
\mathbf{if}\;x \le -7.934591556850648877179646504172286937752 \cdot 10^{139}:\\
\;\;\;\;\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \left(-\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot x\right)\\

\mathbf{elif}\;x \le 1.758065253567775503978920400402254303936 \cdot 10^{99}:\\
\;\;\;\;\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{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \left(\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot x\right)\\

\end{array}
double f(double x, double y, double z) {
        double r587939 = x;
        double r587940 = r587939 * r587939;
        double r587941 = y;
        double r587942 = r587941 * r587941;
        double r587943 = r587940 + r587942;
        double r587944 = z;
        double r587945 = r587944 * r587944;
        double r587946 = r587943 + r587945;
        double r587947 = 3.0;
        double r587948 = r587946 / r587947;
        double r587949 = sqrt(r587948);
        return r587949;
}

double f(double x, double y, double z) {
        double r587950 = x;
        double r587951 = -7.934591556850649e+139;
        bool r587952 = r587950 <= r587951;
        double r587953 = 1.0;
        double r587954 = 3.0;
        double r587955 = cbrt(r587954);
        double r587956 = r587955 * r587955;
        double r587957 = r587953 / r587956;
        double r587958 = sqrt(r587957);
        double r587959 = r587953 / r587955;
        double r587960 = sqrt(r587959);
        double r587961 = r587960 * r587950;
        double r587962 = -r587961;
        double r587963 = r587958 * r587962;
        double r587964 = 1.7580652535677755e+99;
        bool r587965 = r587950 <= r587964;
        double r587966 = r587950 * r587950;
        double r587967 = y;
        double r587968 = r587967 * r587967;
        double r587969 = r587966 + r587968;
        double r587970 = z;
        double r587971 = r587970 * r587970;
        double r587972 = r587969 + r587971;
        double r587973 = sqrt(r587972);
        double r587974 = r587973 / r587956;
        double r587975 = r587973 / r587955;
        double r587976 = r587974 * r587975;
        double r587977 = sqrt(r587976);
        double r587978 = r587958 * r587961;
        double r587979 = r587965 ? r587977 : r587978;
        double r587980 = r587952 ? r587963 : r587979;
        return r587980;
}

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
Target25.6
Herbie25.7
\[\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 < -7.934591556850649e+139

    1. Initial program 60.7

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

      \[\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-identity60.7

      \[\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-frac60.7

      \[\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-prod60.7

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

      \[\leadsto \sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \color{blue}{\left(-1 \cdot \left(\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot x\right)\right)}\]
    8. Simplified14.4

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

    if -7.934591556850649e+139 < x < 1.7580652535677755e+99

    1. Initial program 29.4

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

      \[\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.4

      \[\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.4

      \[\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 1.7580652535677755e+99 < x

    1. Initial program 54.2

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

      \[\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-identity54.2

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

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

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

      \[\leadsto \sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \color{blue}{\left(\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot x\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification25.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -7.934591556850648877179646504172286937752 \cdot 10^{139}:\\ \;\;\;\;\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \left(-\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot x\right)\\ \mathbf{elif}\;x \le 1.758065253567775503978920400402254303936 \cdot 10^{99}:\\ \;\;\;\;\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{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \left(\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019325 
(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)))