Average Error: 38.2 → 26.0
Time: 21.4s
Precision: 64
\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -9.708346480390896462673015323847225793618 \cdot 10^{60}:\\ \;\;\;\;\left(\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot \left(-x\right)\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}\\ \mathbf{elif}\;x \le 5.659091314574308031969886902252890328589 \cdot 10^{100}:\\ \;\;\;\;\sqrt{\sqrt{z \cdot z + \left(y \cdot y + x \cdot x\right)} \cdot \frac{\sqrt{z \cdot z + \left(y \cdot y + x \cdot x\right)}}{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 -9.708346480390896462673015323847225793618 \cdot 10^{60}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot \left(-x\right)\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}\\

\mathbf{elif}\;x \le 5.659091314574308031969886902252890328589 \cdot 10^{100}:\\
\;\;\;\;\sqrt{\sqrt{z \cdot z + \left(y \cdot y + x \cdot x\right)} \cdot \frac{\sqrt{z \cdot z + \left(y \cdot y + x \cdot x\right)}}{3}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r42640063 = x;
        double r42640064 = r42640063 * r42640063;
        double r42640065 = y;
        double r42640066 = r42640065 * r42640065;
        double r42640067 = r42640064 + r42640066;
        double r42640068 = z;
        double r42640069 = r42640068 * r42640068;
        double r42640070 = r42640067 + r42640069;
        double r42640071 = 3.0;
        double r42640072 = r42640070 / r42640071;
        double r42640073 = sqrt(r42640072);
        return r42640073;
}

double f(double x, double y, double z) {
        double r42640074 = x;
        double r42640075 = -9.708346480390896e+60;
        bool r42640076 = r42640074 <= r42640075;
        double r42640077 = 1.0;
        double r42640078 = 3.0;
        double r42640079 = cbrt(r42640078);
        double r42640080 = r42640077 / r42640079;
        double r42640081 = sqrt(r42640080);
        double r42640082 = -r42640074;
        double r42640083 = r42640081 * r42640082;
        double r42640084 = r42640079 * r42640079;
        double r42640085 = r42640077 / r42640084;
        double r42640086 = sqrt(r42640085);
        double r42640087 = r42640083 * r42640086;
        double r42640088 = 5.659091314574308e+100;
        bool r42640089 = r42640074 <= r42640088;
        double r42640090 = z;
        double r42640091 = r42640090 * r42640090;
        double r42640092 = y;
        double r42640093 = r42640092 * r42640092;
        double r42640094 = r42640074 * r42640074;
        double r42640095 = r42640093 + r42640094;
        double r42640096 = r42640091 + r42640095;
        double r42640097 = sqrt(r42640096);
        double r42640098 = r42640097 / r42640078;
        double r42640099 = r42640097 * r42640098;
        double r42640100 = sqrt(r42640099);
        double r42640101 = 0.3333333333333333;
        double r42640102 = sqrt(r42640101);
        double r42640103 = r42640102 * r42640074;
        double r42640104 = r42640089 ? r42640100 : r42640103;
        double r42640105 = r42640076 ? r42640087 : r42640104;
        return r42640105;
}

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.2
Target26.1
Herbie26.0
\[\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 < -9.708346480390896e+60

    1. Initial program 50.5

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

      \[\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-identity50.5

      \[\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-frac50.5

      \[\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-prod50.5

      \[\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 20.1

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

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

    if -9.708346480390896e+60 < x < 5.659091314574308e+100

    1. Initial program 29.7

      \[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity29.7

      \[\leadsto \sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{\color{blue}{1 \cdot 3}}}\]
    4. Applied add-sqr-sqrt29.7

      \[\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}}}{1 \cdot 3}}\]
    5. Applied times-frac29.7

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

    if 5.659091314574308e+100 < x

    1. Initial program 55.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -9.708346480390896462673015323847225793618 \cdot 10^{60}:\\ \;\;\;\;\left(\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot \left(-x\right)\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}\\ \mathbf{elif}\;x \le 5.659091314574308031969886902252890328589 \cdot 10^{100}:\\ \;\;\;\;\sqrt{\sqrt{z \cdot z + \left(y \cdot y + x \cdot x\right)} \cdot \frac{\sqrt{z \cdot z + \left(y \cdot y + x \cdot x\right)}}{3}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.3333333333333333148296162562473909929395} \cdot x\\ \end{array}\]

Reproduce

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