Average Error: 37.7 → 25.7
Time: 18.8s
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 r585281 = x;
        double r585282 = r585281 * r585281;
        double r585283 = y;
        double r585284 = r585283 * r585283;
        double r585285 = r585282 + r585284;
        double r585286 = z;
        double r585287 = r585286 * r585286;
        double r585288 = r585285 + r585287;
        double r585289 = 3.0;
        double r585290 = r585288 / r585289;
        double r585291 = sqrt(r585290);
        return r585291;
}

double f(double x, double y, double z) {
        double r585292 = x;
        double r585293 = -7.934591556850649e+139;
        bool r585294 = r585292 <= r585293;
        double r585295 = 1.0;
        double r585296 = 3.0;
        double r585297 = cbrt(r585296);
        double r585298 = r585297 * r585297;
        double r585299 = r585295 / r585298;
        double r585300 = sqrt(r585299);
        double r585301 = r585295 / r585297;
        double r585302 = sqrt(r585301);
        double r585303 = r585302 * r585292;
        double r585304 = -r585303;
        double r585305 = r585300 * r585304;
        double r585306 = 1.7580652535677755e+99;
        bool r585307 = r585292 <= r585306;
        double r585308 = r585292 * r585292;
        double r585309 = y;
        double r585310 = r585309 * r585309;
        double r585311 = r585308 + r585310;
        double r585312 = z;
        double r585313 = r585312 * r585312;
        double r585314 = r585311 + r585313;
        double r585315 = sqrt(r585314);
        double r585316 = r585315 / r585298;
        double r585317 = r585315 / r585297;
        double r585318 = r585316 * r585317;
        double r585319 = sqrt(r585318);
        double r585320 = r585300 * r585303;
        double r585321 = r585307 ? r585319 : r585320;
        double r585322 = r585294 ? r585305 : r585321;
        return r585322;
}

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