Average Error: 34.9 → 24.6
Time: 10.8s
Precision: 64
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.367949010508958 \cdot 10^{+154}:\\ \;\;\;\;-y\\ \mathbf{elif}\;y \le 7.713534299440976 \cdot 10^{-154}:\\ \;\;\;\;\sqrt{z \cdot z + \left(x \cdot x + y \cdot y\right)}\\ \mathbf{elif}\;y \le 1.1157415651580421 \cdot 10^{-132}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \le 1.1364508215619331 \cdot 10^{+141}:\\ \;\;\;\;\sqrt{z \cdot z + \left(x \cdot x + y \cdot y\right)}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array}\]
\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}
\begin{array}{l}
\mathbf{if}\;y \le -1.367949010508958 \cdot 10^{+154}:\\
\;\;\;\;-y\\

\mathbf{elif}\;y \le 7.713534299440976 \cdot 10^{-154}:\\
\;\;\;\;\sqrt{z \cdot z + \left(x \cdot x + y \cdot y\right)}\\

\mathbf{elif}\;y \le 1.1157415651580421 \cdot 10^{-132}:\\
\;\;\;\;z\\

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

\mathbf{else}:\\
\;\;\;\;y\\

\end{array}
double f(double x, double y, double z) {
        double r33843522 = x;
        double r33843523 = r33843522 * r33843522;
        double r33843524 = y;
        double r33843525 = r33843524 * r33843524;
        double r33843526 = r33843523 + r33843525;
        double r33843527 = z;
        double r33843528 = r33843527 * r33843527;
        double r33843529 = r33843526 + r33843528;
        double r33843530 = sqrt(r33843529);
        return r33843530;
}

double f(double x, double y, double z) {
        double r33843531 = y;
        double r33843532 = -1.367949010508958e+154;
        bool r33843533 = r33843531 <= r33843532;
        double r33843534 = -r33843531;
        double r33843535 = 7.713534299440976e-154;
        bool r33843536 = r33843531 <= r33843535;
        double r33843537 = z;
        double r33843538 = r33843537 * r33843537;
        double r33843539 = x;
        double r33843540 = r33843539 * r33843539;
        double r33843541 = r33843531 * r33843531;
        double r33843542 = r33843540 + r33843541;
        double r33843543 = r33843538 + r33843542;
        double r33843544 = sqrt(r33843543);
        double r33843545 = 1.1157415651580421e-132;
        bool r33843546 = r33843531 <= r33843545;
        double r33843547 = 1.1364508215619331e+141;
        bool r33843548 = r33843531 <= r33843547;
        double r33843549 = r33843548 ? r33843544 : r33843531;
        double r33843550 = r33843546 ? r33843537 : r33843549;
        double r33843551 = r33843536 ? r33843544 : r33843550;
        double r33843552 = r33843533 ? r33843534 : r33843551;
        return r33843552;
}

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

Original34.9
Target23.3
Herbie24.6
\[\begin{array}{l} \mathbf{if}\;z \lt -6.396479394109776 \cdot 10^{+136}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \lt 7.320293694404182 \cdot 10^{+117}:\\ \;\;\;\;\sqrt{\left(z \cdot z + x \cdot x\right) + y \cdot y}\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array}\]

Derivation

  1. Split input into 4 regimes
  2. if y < -1.367949010508958e+154

    1. Initial program 59.2

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

      \[\leadsto \color{blue}{\sqrt[3]{\left(\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}\right) \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}}\]
    4. Simplified59.2

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

      \[\leadsto \color{blue}{-1 \cdot y}\]
    6. Simplified13.7

      \[\leadsto \color{blue}{-y}\]

    if -1.367949010508958e+154 < y < 7.713534299440976e-154 or 1.1157415651580421e-132 < y < 1.1364508215619331e+141

    1. Initial program 27.4

      \[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]

    if 7.713534299440976e-154 < y < 1.1157415651580421e-132

    1. Initial program 28.7

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

      \[\leadsto \color{blue}{z}\]

    if 1.1364508215619331e+141 < y

    1. Initial program 56.7

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

      \[\leadsto \color{blue}{\sqrt[3]{\left(\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}\right) \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}}\]
    4. Simplified59.3

      \[\leadsto \sqrt[3]{\color{blue}{\left(y \cdot y + \left(x \cdot x + z \cdot z\right)\right) \cdot \sqrt{y \cdot y + \left(x \cdot x + z \cdot z\right)}}}\]
    5. Taylor expanded around inf 15.2

      \[\leadsto \color{blue}{y}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification24.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.367949010508958 \cdot 10^{+154}:\\ \;\;\;\;-y\\ \mathbf{elif}\;y \le 7.713534299440976 \cdot 10^{-154}:\\ \;\;\;\;\sqrt{z \cdot z + \left(x \cdot x + y \cdot y\right)}\\ \mathbf{elif}\;y \le 1.1157415651580421 \cdot 10^{-132}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \le 1.1364508215619331 \cdot 10^{+141}:\\ \;\;\;\;\sqrt{z \cdot z + \left(x \cdot x + y \cdot y\right)}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array}\]

Reproduce

herbie shell --seed 2019158 
(FPCore (x y z)
  :name "FRP.Yampa.Vector3:vector3Rho from Yampa-0.10.2"

  :herbie-target
  (if (< z -6.396479394109776e+136) (- z) (if (< z 7.320293694404182e+117) (sqrt (+ (+ (* z z) (* x x)) (* y y))) z))

  (sqrt (+ (+ (* x x) (* y y)) (* z z))))