Average Error: 38.6 → 25.9
Time: 1.4s
Precision: 64
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.92240592229415833 \cdot 10^{130}:\\ \;\;\;\;-1 \cdot x\\ \mathbf{elif}\;x \le 7.6477979095530901 \cdot 10^{93}:\\ \;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -6.92240592229415833 \cdot 10^{130}:\\
\;\;\;\;-1 \cdot x\\

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

\mathbf{else}:\\
\;\;\;\;x\\

\end{array}
double f(double x, double y, double z) {
        double r609304 = x;
        double r609305 = r609304 * r609304;
        double r609306 = y;
        double r609307 = r609306 * r609306;
        double r609308 = r609305 + r609307;
        double r609309 = z;
        double r609310 = r609309 * r609309;
        double r609311 = r609308 + r609310;
        double r609312 = sqrt(r609311);
        return r609312;
}

double f(double x, double y, double z) {
        double r609313 = x;
        double r609314 = -6.922405922294158e+130;
        bool r609315 = r609313 <= r609314;
        double r609316 = -1.0;
        double r609317 = r609316 * r609313;
        double r609318 = 7.64779790955309e+93;
        bool r609319 = r609313 <= r609318;
        double r609320 = r609313 * r609313;
        double r609321 = y;
        double r609322 = r609321 * r609321;
        double r609323 = r609320 + r609322;
        double r609324 = z;
        double r609325 = r609324 * r609324;
        double r609326 = r609323 + r609325;
        double r609327 = sqrt(r609326);
        double r609328 = r609319 ? r609327 : r609313;
        double r609329 = r609315 ? r609317 : r609328;
        return r609329;
}

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

Original38.6
Target26.1
Herbie25.9
\[\begin{array}{l} \mathbf{if}\;z \lt -6.3964793941097758 \cdot 10^{136}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \lt 7.3202936944041821 \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 3 regimes
  2. if x < -6.922405922294158e+130

    1. Initial program 59.4

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

      \[\leadsto \color{blue}{-1 \cdot x}\]

    if -6.922405922294158e+130 < x < 7.64779790955309e+93

    1. Initial program 29.7

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

    if 7.64779790955309e+93 < x

    1. Initial program 55.3

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

      \[\leadsto \color{blue}{x}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification25.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -6.92240592229415833 \cdot 10^{130}:\\ \;\;\;\;-1 \cdot x\\ \mathbf{elif}\;x \le 7.6477979095530901 \cdot 10^{93}:\\ \;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]

Reproduce

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

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