Average Error: 37.6 → 25.5
Time: 4.6s
Precision: 64
\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.67286222885243723 \cdot 10^{149}:\\ \;\;\;\;\sqrt{\sqrt{0.333333333333333315}} \cdot \left(\sqrt{\sqrt{0.333333333333333315}} \cdot \left(-1 \cdot x\right)\right)\\ \mathbf{elif}\;x \le 8.4296792906958425 \cdot 10^{116}:\\ \;\;\;\;\sqrt{0.333333333333333315 \cdot \left(\left(x \cdot x + y \cdot y\right) + z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\sqrt{0.333333333333333315}} \cdot \left(\sqrt{\sqrt{0.333333333333333315}} \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 -3.67286222885243723 \cdot 10^{149}:\\
\;\;\;\;\sqrt{\sqrt{0.333333333333333315}} \cdot \left(\sqrt{\sqrt{0.333333333333333315}} \cdot \left(-1 \cdot x\right)\right)\\

\mathbf{elif}\;x \le 8.4296792906958425 \cdot 10^{116}:\\
\;\;\;\;\sqrt{0.333333333333333315 \cdot \left(\left(x \cdot x + y \cdot y\right) + z \cdot z\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\sqrt{0.333333333333333315}} \cdot \left(\sqrt{\sqrt{0.333333333333333315}} \cdot x\right)\\

\end{array}
double f(double x, double y, double z) {
        double r985723 = x;
        double r985724 = r985723 * r985723;
        double r985725 = y;
        double r985726 = r985725 * r985725;
        double r985727 = r985724 + r985726;
        double r985728 = z;
        double r985729 = r985728 * r985728;
        double r985730 = r985727 + r985729;
        double r985731 = 3.0;
        double r985732 = r985730 / r985731;
        double r985733 = sqrt(r985732);
        return r985733;
}

double f(double x, double y, double z) {
        double r985734 = x;
        double r985735 = -3.6728622288524372e+149;
        bool r985736 = r985734 <= r985735;
        double r985737 = 0.3333333333333333;
        double r985738 = sqrt(r985737);
        double r985739 = sqrt(r985738);
        double r985740 = -1.0;
        double r985741 = r985740 * r985734;
        double r985742 = r985739 * r985741;
        double r985743 = r985739 * r985742;
        double r985744 = 8.429679290695843e+116;
        bool r985745 = r985734 <= r985744;
        double r985746 = r985734 * r985734;
        double r985747 = y;
        double r985748 = r985747 * r985747;
        double r985749 = r985746 + r985748;
        double r985750 = z;
        double r985751 = r985750 * r985750;
        double r985752 = r985749 + r985751;
        double r985753 = r985737 * r985752;
        double r985754 = sqrt(r985753);
        double r985755 = r985739 * r985734;
        double r985756 = r985739 * r985755;
        double r985757 = r985745 ? r985754 : r985756;
        double r985758 = r985736 ? r985743 : r985757;
        return r985758;
}

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.6
Target25.2
Herbie25.5
\[\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 < -3.6728622288524372e+149

    1. Initial program 62.6

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

      \[\leadsto \sqrt{\color{blue}{0.333333333333333315 \cdot {x}^{2} + \left(0.333333333333333315 \cdot {y}^{2} + 0.333333333333333315 \cdot {z}^{2}\right)}}\]
    3. Simplified62.6

      \[\leadsto \sqrt{\color{blue}{0.333333333333333315 \cdot \left(\left(x \cdot x + y \cdot y\right) + z \cdot z\right)}}\]
    4. Using strategy rm
    5. Applied sqrt-prod62.6

      \[\leadsto \color{blue}{\sqrt{0.333333333333333315} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt62.6

      \[\leadsto \sqrt{\color{blue}{\sqrt{0.333333333333333315} \cdot \sqrt{0.333333333333333315}}} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
    8. Applied sqrt-prod62.6

      \[\leadsto \color{blue}{\left(\sqrt{\sqrt{0.333333333333333315}} \cdot \sqrt{\sqrt{0.333333333333333315}}\right)} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
    9. Applied associate-*l*62.6

      \[\leadsto \color{blue}{\sqrt{\sqrt{0.333333333333333315}} \cdot \left(\sqrt{\sqrt{0.333333333333333315}} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\right)}\]
    10. Taylor expanded around -inf 14.2

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

    if -3.6728622288524372e+149 < x < 8.429679290695843e+116

    1. Initial program 29.4

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

      \[\leadsto \sqrt{\color{blue}{0.333333333333333315 \cdot {x}^{2} + \left(0.333333333333333315 \cdot {y}^{2} + 0.333333333333333315 \cdot {z}^{2}\right)}}\]
    3. Simplified29.4

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

    if 8.429679290695843e+116 < x

    1. Initial program 56.3

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

      \[\leadsto \sqrt{\color{blue}{0.333333333333333315 \cdot {x}^{2} + \left(0.333333333333333315 \cdot {y}^{2} + 0.333333333333333315 \cdot {z}^{2}\right)}}\]
    3. Simplified56.3

      \[\leadsto \sqrt{\color{blue}{0.333333333333333315 \cdot \left(\left(x \cdot x + y \cdot y\right) + z \cdot z\right)}}\]
    4. Using strategy rm
    5. Applied sqrt-prod56.3

      \[\leadsto \color{blue}{\sqrt{0.333333333333333315} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt56.3

      \[\leadsto \sqrt{\color{blue}{\sqrt{0.333333333333333315} \cdot \sqrt{0.333333333333333315}}} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
    8. Applied sqrt-prod56.3

      \[\leadsto \color{blue}{\left(\sqrt{\sqrt{0.333333333333333315}} \cdot \sqrt{\sqrt{0.333333333333333315}}\right)} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
    9. Applied associate-*l*56.3

      \[\leadsto \color{blue}{\sqrt{\sqrt{0.333333333333333315}} \cdot \left(\sqrt{\sqrt{0.333333333333333315}} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\right)}\]
    10. Taylor expanded around inf 16.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.67286222885243723 \cdot 10^{149}:\\ \;\;\;\;\sqrt{\sqrt{0.333333333333333315}} \cdot \left(\sqrt{\sqrt{0.333333333333333315}} \cdot \left(-1 \cdot x\right)\right)\\ \mathbf{elif}\;x \le 8.4296792906958425 \cdot 10^{116}:\\ \;\;\;\;\sqrt{0.333333333333333315 \cdot \left(\left(x \cdot x + y \cdot y\right) + z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\sqrt{0.333333333333333315}} \cdot \left(\sqrt{\sqrt{0.333333333333333315}} \cdot x\right)\\ \end{array}\]

Reproduce

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