Average Error: 37.8 → 25.9
Time: 19.3s
Precision: 64
\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -8.211230074550794807852274410189304665365 \cdot 10^{53}:\\ \;\;\;\;\left(x \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\right) \cdot \left(-\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}\right)\\ \mathbf{elif}\;x \le 7.495231207769666567884408344017044329315 \cdot 10^{94}:\\ \;\;\;\;\sqrt{\frac{1}{\frac{3}{z \cdot z + \left(y \cdot y + x \cdot x\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}\\ \end{array}\]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\begin{array}{l}
\mathbf{if}\;x \le -8.211230074550794807852274410189304665365 \cdot 10^{53}:\\
\;\;\;\;\left(x \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\right) \cdot \left(-\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}\right)\\

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

\mathbf{else}:\\
\;\;\;\;\left(x \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}\\

\end{array}
double f(double x, double y, double z) {
        double r41324734 = x;
        double r41324735 = r41324734 * r41324734;
        double r41324736 = y;
        double r41324737 = r41324736 * r41324736;
        double r41324738 = r41324735 + r41324737;
        double r41324739 = z;
        double r41324740 = r41324739 * r41324739;
        double r41324741 = r41324738 + r41324740;
        double r41324742 = 3.0;
        double r41324743 = r41324741 / r41324742;
        double r41324744 = sqrt(r41324743);
        return r41324744;
}

double f(double x, double y, double z) {
        double r41324745 = x;
        double r41324746 = -8.211230074550795e+53;
        bool r41324747 = r41324745 <= r41324746;
        double r41324748 = 1.0;
        double r41324749 = 3.0;
        double r41324750 = cbrt(r41324749);
        double r41324751 = r41324748 / r41324750;
        double r41324752 = sqrt(r41324751);
        double r41324753 = r41324745 * r41324752;
        double r41324754 = r41324750 * r41324750;
        double r41324755 = r41324748 / r41324754;
        double r41324756 = sqrt(r41324755);
        double r41324757 = -r41324756;
        double r41324758 = r41324753 * r41324757;
        double r41324759 = 7.495231207769667e+94;
        bool r41324760 = r41324745 <= r41324759;
        double r41324761 = z;
        double r41324762 = r41324761 * r41324761;
        double r41324763 = y;
        double r41324764 = r41324763 * r41324763;
        double r41324765 = r41324745 * r41324745;
        double r41324766 = r41324764 + r41324765;
        double r41324767 = r41324762 + r41324766;
        double r41324768 = r41324749 / r41324767;
        double r41324769 = r41324748 / r41324768;
        double r41324770 = sqrt(r41324769);
        double r41324771 = r41324753 * r41324756;
        double r41324772 = r41324760 ? r41324770 : r41324771;
        double r41324773 = r41324747 ? r41324758 : r41324772;
        return r41324773;
}

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.8
Target25.8
Herbie25.9
\[\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 < -8.211230074550795e+53

    1. Initial program 49.1

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

      \[\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-identity49.1

      \[\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-frac49.1

      \[\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-prod49.1

      \[\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 21.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. Simplified21.1

      \[\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 -8.211230074550795e+53 < x < 7.495231207769667e+94

    1. Initial program 29.8

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

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

    if 7.495231207769667e+94 < x

    1. Initial program 52.8

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

      \[\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-identity52.8

      \[\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-frac52.8

      \[\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-prod52.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -8.211230074550794807852274410189304665365 \cdot 10^{53}:\\ \;\;\;\;\left(x \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\right) \cdot \left(-\sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}\right)\\ \mathbf{elif}\;x \le 7.495231207769666567884408344017044329315 \cdot 10^{94}:\\ \;\;\;\;\sqrt{\frac{1}{\frac{3}{z \cdot z + \left(y \cdot y + x \cdot x\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \sqrt{\frac{1}{\sqrt[3]{3}}}\right) \cdot \sqrt{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}\\ \end{array}\]

Reproduce

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