Average Error: 28.0 → 13.8
Time: 10.0s
Precision: 64
\[\sqrt{\left(1 + {x}^{2}\right) + {y}^{2}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.303209947657204342880384766533788360025 \cdot 10^{84}:\\ \;\;\;\;\left(-x\right) - \frac{0.5}{x}\\ \mathbf{elif}\;x \le 1.943934747643531875760607600817076209382 \cdot 10^{128}:\\ \;\;\;\;\sqrt{\left(1 + {x}^{2}\right) + {y}^{2}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{0.5}{x}\\ \end{array}\]
\sqrt{\left(1 + {x}^{2}\right) + {y}^{2}}
\begin{array}{l}
\mathbf{if}\;x \le -3.303209947657204342880384766533788360025 \cdot 10^{84}:\\
\;\;\;\;\left(-x\right) - \frac{0.5}{x}\\

\mathbf{elif}\;x \le 1.943934747643531875760607600817076209382 \cdot 10^{128}:\\
\;\;\;\;\sqrt{\left(1 + {x}^{2}\right) + {y}^{2}}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{0.5}{x}\\

\end{array}
double f(double x, double y) {
        double r192446 = 1.0;
        double r192447 = x;
        double r192448 = 2.0;
        double r192449 = pow(r192447, r192448);
        double r192450 = r192446 + r192449;
        double r192451 = y;
        double r192452 = pow(r192451, r192448);
        double r192453 = r192450 + r192452;
        double r192454 = sqrt(r192453);
        return r192454;
}

double f(double x, double y) {
        double r192455 = x;
        double r192456 = -3.3032099476572043e+84;
        bool r192457 = r192455 <= r192456;
        double r192458 = -r192455;
        double r192459 = 0.5;
        double r192460 = r192459 / r192455;
        double r192461 = r192458 - r192460;
        double r192462 = 1.943934747643532e+128;
        bool r192463 = r192455 <= r192462;
        double r192464 = 1.0;
        double r192465 = 2.0;
        double r192466 = pow(r192455, r192465);
        double r192467 = r192464 + r192466;
        double r192468 = y;
        double r192469 = pow(r192468, r192465);
        double r192470 = r192467 + r192469;
        double r192471 = sqrt(r192470);
        double r192472 = r192455 + r192460;
        double r192473 = r192463 ? r192471 : r192472;
        double r192474 = r192457 ? r192461 : r192473;
        return r192474;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if x < -3.3032099476572043e+84

    1. Initial program 48.4

      \[\sqrt{\left(1 + {x}^{2}\right) + {y}^{2}}\]
    2. Taylor expanded around -inf 10.3

      \[\leadsto \color{blue}{-\left(x + 0.5 \cdot \frac{1}{x}\right)}\]
    3. Simplified10.3

      \[\leadsto \color{blue}{\left(-x\right) - \frac{0.5}{x}}\]

    if -3.3032099476572043e+84 < x < 1.943934747643532e+128

    1. Initial program 16.0

      \[\sqrt{\left(1 + {x}^{2}\right) + {y}^{2}}\]

    if 1.943934747643532e+128 < x

    1. Initial program 57.0

      \[\sqrt{\left(1 + {x}^{2}\right) + {y}^{2}}\]
    2. Taylor expanded around inf 8.2

      \[\leadsto \color{blue}{x + 0.5 \cdot \frac{1}{x}}\]
    3. Simplified8.2

      \[\leadsto \color{blue}{x + \frac{0.5}{x}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification13.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.303209947657204342880384766533788360025 \cdot 10^{84}:\\ \;\;\;\;\left(-x\right) - \frac{0.5}{x}\\ \mathbf{elif}\;x \le 1.943934747643531875760607600817076209382 \cdot 10^{128}:\\ \;\;\;\;\sqrt{\left(1 + {x}^{2}\right) + {y}^{2}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{0.5}{x}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (x y)
  :name "sqrt(1+x^2 +y^2)"
  :precision binary64
  (sqrt (+ (+ 1 (pow x 2)) (pow y 2))))