Average Error: 37.5 → 18.2
Time: 14.1s
Precision: 64
\[\sqrt{2 \cdot \left(\sqrt{x \cdot x + y \cdot y} + x\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \le -4.948787994215982 \cdot 10^{+143}:\\ \;\;\;\;\frac{\sqrt{\left(y \cdot y\right) \cdot 2}}{\sqrt{x \cdot -2}}\\ \mathbf{elif}\;x \le -9.361038594997412 \cdot 10^{-293}:\\ \;\;\;\;\frac{\left|y\right|}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}} \cdot \frac{\sqrt{2}}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}}\\ \mathbf{elif}\;x \le 6.586100699332152 \cdot 10^{+127}:\\ \;\;\;\;\sqrt{2 \cdot \left(x + \sqrt{x \cdot x + y \cdot y}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(x + x\right) \cdot 2}\\ \end{array}\]
\sqrt{2 \cdot \left(\sqrt{x \cdot x + y \cdot y} + x\right)}
\begin{array}{l}
\mathbf{if}\;x \le -4.948787994215982 \cdot 10^{+143}:\\
\;\;\;\;\frac{\sqrt{\left(y \cdot y\right) \cdot 2}}{\sqrt{x \cdot -2}}\\

\mathbf{elif}\;x \le -9.361038594997412 \cdot 10^{-293}:\\
\;\;\;\;\frac{\left|y\right|}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}} \cdot \frac{\sqrt{2}}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}}\\

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

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

\end{array}
double f(double x, double y) {
        double r17317467 = 2.0;
        double r17317468 = x;
        double r17317469 = r17317468 * r17317468;
        double r17317470 = y;
        double r17317471 = r17317470 * r17317470;
        double r17317472 = r17317469 + r17317471;
        double r17317473 = sqrt(r17317472);
        double r17317474 = r17317473 + r17317468;
        double r17317475 = r17317467 * r17317474;
        double r17317476 = sqrt(r17317475);
        return r17317476;
}

double f(double x, double y) {
        double r17317477 = x;
        double r17317478 = -4.948787994215982e+143;
        bool r17317479 = r17317477 <= r17317478;
        double r17317480 = y;
        double r17317481 = r17317480 * r17317480;
        double r17317482 = 2.0;
        double r17317483 = r17317481 * r17317482;
        double r17317484 = sqrt(r17317483);
        double r17317485 = -2.0;
        double r17317486 = r17317477 * r17317485;
        double r17317487 = sqrt(r17317486);
        double r17317488 = r17317484 / r17317487;
        double r17317489 = -9.361038594997412e-293;
        bool r17317490 = r17317477 <= r17317489;
        double r17317491 = fabs(r17317480);
        double r17317492 = r17317477 * r17317477;
        double r17317493 = r17317492 + r17317481;
        double r17317494 = sqrt(r17317493);
        double r17317495 = r17317494 - r17317477;
        double r17317496 = sqrt(r17317495);
        double r17317497 = sqrt(r17317496);
        double r17317498 = r17317491 / r17317497;
        double r17317499 = sqrt(r17317482);
        double r17317500 = r17317499 / r17317497;
        double r17317501 = r17317498 * r17317500;
        double r17317502 = 6.586100699332152e+127;
        bool r17317503 = r17317477 <= r17317502;
        double r17317504 = r17317477 + r17317494;
        double r17317505 = r17317482 * r17317504;
        double r17317506 = sqrt(r17317505);
        double r17317507 = r17317477 + r17317477;
        double r17317508 = r17317507 * r17317482;
        double r17317509 = sqrt(r17317508);
        double r17317510 = r17317503 ? r17317506 : r17317509;
        double r17317511 = r17317490 ? r17317501 : r17317510;
        double r17317512 = r17317479 ? r17317488 : r17317511;
        return r17317512;
}

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 4 regimes
  2. if x < -4.948787994215982e+143

    1. Initial program 61.7

      \[\sqrt{2 \cdot \left(\sqrt{x \cdot x + y \cdot y} + x\right)}\]
    2. Using strategy rm
    3. Applied flip-+61.7

      \[\leadsto \sqrt{2 \cdot \color{blue}{\frac{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y} - x \cdot x}{\sqrt{x \cdot x + y \cdot y} - x}}}\]
    4. Applied associate-*r/61.7

      \[\leadsto \sqrt{\color{blue}{\frac{2 \cdot \left(\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y} - x \cdot x\right)}{\sqrt{x \cdot x + y \cdot y} - x}}}\]
    5. Applied sqrt-div61.7

      \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot \left(\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y} - x \cdot x\right)}}{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}}\]
    6. Simplified47.4

      \[\leadsto \frac{\color{blue}{\sqrt{\left(y \cdot y + 0\right) \cdot 2}}}{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}\]
    7. Taylor expanded around -inf 20.3

      \[\leadsto \frac{\sqrt{\left(y \cdot y + 0\right) \cdot 2}}{\sqrt{\color{blue}{-2 \cdot x}}}\]

    if -4.948787994215982e+143 < x < -9.361038594997412e-293

    1. Initial program 39.2

      \[\sqrt{2 \cdot \left(\sqrt{x \cdot x + y \cdot y} + x\right)}\]
    2. Using strategy rm
    3. Applied flip-+39.1

      \[\leadsto \sqrt{2 \cdot \color{blue}{\frac{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y} - x \cdot x}{\sqrt{x \cdot x + y \cdot y} - x}}}\]
    4. Applied associate-*r/39.1

      \[\leadsto \sqrt{\color{blue}{\frac{2 \cdot \left(\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y} - x \cdot x\right)}{\sqrt{x \cdot x + y \cdot y} - x}}}\]
    5. Applied sqrt-div39.2

      \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot \left(\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y} - x \cdot x\right)}}{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}}\]
    6. Simplified28.4

      \[\leadsto \frac{\color{blue}{\sqrt{\left(y \cdot y + 0\right) \cdot 2}}}{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt28.6

      \[\leadsto \frac{\sqrt{\left(y \cdot y + 0\right) \cdot 2}}{\color{blue}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}} \cdot \sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}}}\]
    9. Applied sqrt-prod28.6

      \[\leadsto \frac{\color{blue}{\sqrt{y \cdot y + 0} \cdot \sqrt{2}}}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}} \cdot \sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}}\]
    10. Applied times-frac28.6

      \[\leadsto \color{blue}{\frac{\sqrt{y \cdot y + 0}}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}} \cdot \frac{\sqrt{2}}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}}}\]
    11. Simplified19.5

      \[\leadsto \color{blue}{\frac{\left|y\right|}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}}} \cdot \frac{\sqrt{2}}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}}\]

    if -9.361038594997412e-293 < x < 6.586100699332152e+127

    1. Initial program 20.2

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

    if 6.586100699332152e+127 < x

    1. Initial program 54.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.948787994215982 \cdot 10^{+143}:\\ \;\;\;\;\frac{\sqrt{\left(y \cdot y\right) \cdot 2}}{\sqrt{x \cdot -2}}\\ \mathbf{elif}\;x \le -9.361038594997412 \cdot 10^{-293}:\\ \;\;\;\;\frac{\left|y\right|}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}} \cdot \frac{\sqrt{2}}{\sqrt{\sqrt{\sqrt{x \cdot x + y \cdot y} - x}}}\\ \mathbf{elif}\;x \le 6.586100699332152 \cdot 10^{+127}:\\ \;\;\;\;\sqrt{2 \cdot \left(x + \sqrt{x \cdot x + y \cdot y}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(x + x\right) \cdot 2}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (x y)
  :name "sqrt(2*(sqrt(x*x+y*y)+x))"
  (sqrt (* 2 (+ (sqrt (+ (* x x) (* y y))) x))))