Average Error: 37.5 → 25.0
Time: 5.6s
Precision: 64
\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.6174687293654252 \cdot 10^{118}:\\ \;\;\;\;\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \left(-1 \cdot \left(\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot x\right)\right)\\ \mathbf{elif}\;x \le 1.3566371815103393 \cdot 10^{105}:\\ \;\;\;\;\sqrt{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \cdot \frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{3}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \sqrt{0.333333333333333315}\\ \end{array}\]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\begin{array}{l}
\mathbf{if}\;x \le -1.6174687293654252 \cdot 10^{118}:\\
\;\;\;\;\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \left(-1 \cdot \left(\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot x\right)\right)\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r1039020 = x;
        double r1039021 = r1039020 * r1039020;
        double r1039022 = y;
        double r1039023 = r1039022 * r1039022;
        double r1039024 = r1039021 + r1039023;
        double r1039025 = z;
        double r1039026 = r1039025 * r1039025;
        double r1039027 = r1039024 + r1039026;
        double r1039028 = 3.0;
        double r1039029 = r1039027 / r1039028;
        double r1039030 = sqrt(r1039029);
        return r1039030;
}

double f(double x, double y, double z) {
        double r1039031 = x;
        double r1039032 = -1.6174687293654252e+118;
        bool r1039033 = r1039031 <= r1039032;
        double r1039034 = 1.0;
        double r1039035 = 3.0;
        double r1039036 = cbrt(r1039035);
        double r1039037 = r1039036 * r1039036;
        double r1039038 = r1039034 / r1039037;
        double r1039039 = sqrt(r1039038);
        double r1039040 = -1.0;
        double r1039041 = r1039034 / r1039036;
        double r1039042 = sqrt(r1039041);
        double r1039043 = r1039042 * r1039031;
        double r1039044 = r1039040 * r1039043;
        double r1039045 = r1039039 * r1039044;
        double r1039046 = 1.3566371815103393e+105;
        bool r1039047 = r1039031 <= r1039046;
        double r1039048 = r1039031 * r1039031;
        double r1039049 = y;
        double r1039050 = r1039049 * r1039049;
        double r1039051 = r1039048 + r1039050;
        double r1039052 = z;
        double r1039053 = r1039052 * r1039052;
        double r1039054 = r1039051 + r1039053;
        double r1039055 = sqrt(r1039054);
        double r1039056 = r1039055 / r1039035;
        double r1039057 = r1039055 * r1039056;
        double r1039058 = sqrt(r1039057);
        double r1039059 = 0.3333333333333333;
        double r1039060 = sqrt(r1039059);
        double r1039061 = r1039031 * r1039060;
        double r1039062 = r1039047 ? r1039058 : r1039061;
        double r1039063 = r1039033 ? r1039045 : r1039062;
        return r1039063;
}

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.5
Target25.2
Herbie25.0
\[\begin{array}{l} \mathbf{if}\;z \lt -6.3964793941097758 \cdot 10^{136}:\\ \;\;\;\;\frac{-z}{\sqrt{3}}\\ \mathbf{elif}\;z \lt 7.3202936944041821 \cdot 10^{117}:\\ \;\;\;\;\frac{\sqrt{\left(z \cdot z + x \cdot x\right) + y \cdot y}}{\sqrt{3}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.333333333333333315} \cdot z\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -1.6174687293654252e+118

    1. Initial program 57.3

      \[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt57.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 *-un-lft-identity57.3

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

      \[\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-prod57.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 16.8

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

    if -1.6174687293654252e+118 < x < 1.3566371815103393e+105

    1. Initial program 28.6

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

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

      \[\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-frac28.6

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

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

    if 1.3566371815103393e+105 < x

    1. Initial program 55.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.6174687293654252 \cdot 10^{118}:\\ \;\;\;\;\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}} \cdot \left(-1 \cdot \left(\sqrt{\frac{1}{\sqrt[3]{3}}} \cdot x\right)\right)\\ \mathbf{elif}\;x \le 1.3566371815103393 \cdot 10^{105}:\\ \;\;\;\;\sqrt{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \cdot \frac{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}{3}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \sqrt{0.333333333333333315}\\ \end{array}\]

Reproduce

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