Average Error: 37.5 → 18.1
Time: 12.9s
Precision: 64
\[\sqrt{2.0 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} + xre\right)}\]
\[\begin{array}{l} \mathbf{if}\;xre \le -6.665919659068495 \cdot 10^{+150}:\\ \;\;\;\;\frac{\sqrt{\left(xim \cdot xim\right) \cdot 2.0}}{\sqrt{xre \cdot -2}}\\ \mathbf{elif}\;xre \le -3.400489128496058 \cdot 10^{-295}:\\ \;\;\;\;\left|xim\right| \cdot \frac{\sqrt{2.0}}{\sqrt{\sqrt{xim \cdot xim + xre \cdot xre} - xre}}\\ \mathbf{elif}\;xre \le 1.6283846254691497 \cdot 10^{+127}:\\ \;\;\;\;\sqrt{2.0 \cdot \left(\sqrt{xim \cdot xim + xre \cdot xre} + xre\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(xre + xre\right) \cdot 2.0}\\ \end{array}\]
\sqrt{2.0 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} + xre\right)}
\begin{array}{l}
\mathbf{if}\;xre \le -6.665919659068495 \cdot 10^{+150}:\\
\;\;\;\;\frac{\sqrt{\left(xim \cdot xim\right) \cdot 2.0}}{\sqrt{xre \cdot -2}}\\

\mathbf{elif}\;xre \le -3.400489128496058 \cdot 10^{-295}:\\
\;\;\;\;\left|xim\right| \cdot \frac{\sqrt{2.0}}{\sqrt{\sqrt{xim \cdot xim + xre \cdot xre} - xre}}\\

\mathbf{elif}\;xre \le 1.6283846254691497 \cdot 10^{+127}:\\
\;\;\;\;\sqrt{2.0 \cdot \left(\sqrt{xim \cdot xim + xre \cdot xre} + xre\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(xre + xre\right) \cdot 2.0}\\

\end{array}
double f(double xre, double xim) {
        double r43915508 = 2.0;
        double r43915509 = xre;
        double r43915510 = r43915509 * r43915509;
        double r43915511 = xim;
        double r43915512 = r43915511 * r43915511;
        double r43915513 = r43915510 + r43915512;
        double r43915514 = sqrt(r43915513);
        double r43915515 = r43915514 + r43915509;
        double r43915516 = r43915508 * r43915515;
        double r43915517 = sqrt(r43915516);
        return r43915517;
}

double f(double xre, double xim) {
        double r43915518 = xre;
        double r43915519 = -6.665919659068495e+150;
        bool r43915520 = r43915518 <= r43915519;
        double r43915521 = xim;
        double r43915522 = r43915521 * r43915521;
        double r43915523 = 2.0;
        double r43915524 = r43915522 * r43915523;
        double r43915525 = sqrt(r43915524);
        double r43915526 = -2.0;
        double r43915527 = r43915518 * r43915526;
        double r43915528 = sqrt(r43915527);
        double r43915529 = r43915525 / r43915528;
        double r43915530 = -3.400489128496058e-295;
        bool r43915531 = r43915518 <= r43915530;
        double r43915532 = fabs(r43915521);
        double r43915533 = sqrt(r43915523);
        double r43915534 = r43915518 * r43915518;
        double r43915535 = r43915522 + r43915534;
        double r43915536 = sqrt(r43915535);
        double r43915537 = r43915536 - r43915518;
        double r43915538 = sqrt(r43915537);
        double r43915539 = r43915533 / r43915538;
        double r43915540 = r43915532 * r43915539;
        double r43915541 = 1.6283846254691497e+127;
        bool r43915542 = r43915518 <= r43915541;
        double r43915543 = r43915536 + r43915518;
        double r43915544 = r43915523 * r43915543;
        double r43915545 = sqrt(r43915544);
        double r43915546 = r43915518 + r43915518;
        double r43915547 = r43915546 * r43915523;
        double r43915548 = sqrt(r43915547);
        double r43915549 = r43915542 ? r43915545 : r43915548;
        double r43915550 = r43915531 ? r43915540 : r43915549;
        double r43915551 = r43915520 ? r43915529 : r43915550;
        return r43915551;
}

Error

Bits error versus xre

Bits error versus xim

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if xre < -6.665919659068495e+150

    1. Initial program 62.0

      \[\sqrt{2.0 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} + xre\right)}\]
    2. Using strategy rm
    3. Applied flip-+62.0

      \[\leadsto \sqrt{2.0 \cdot \color{blue}{\frac{\sqrt{xre \cdot xre + xim \cdot xim} \cdot \sqrt{xre \cdot xre + xim \cdot xim} - xre \cdot xre}{\sqrt{xre \cdot xre + xim \cdot xim} - xre}}}\]
    4. Applied associate-*r/62.0

      \[\leadsto \sqrt{\color{blue}{\frac{2.0 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} \cdot \sqrt{xre \cdot xre + xim \cdot xim} - xre \cdot xre\right)}{\sqrt{xre \cdot xre + xim \cdot xim} - xre}}}\]
    5. Applied sqrt-div62.0

      \[\leadsto \color{blue}{\frac{\sqrt{2.0 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} \cdot \sqrt{xre \cdot xre + xim \cdot xim} - xre \cdot xre\right)}}{\sqrt{\sqrt{xre \cdot xre + xim \cdot xim} - xre}}}\]
    6. Simplified48.5

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

      \[\leadsto \frac{\sqrt{\left(xim \cdot xim + 0\right) \cdot 2.0}}{\sqrt{\color{blue}{-2 \cdot xre}}}\]

    if -6.665919659068495e+150 < xre < -3.400489128496058e-295

    1. Initial program 39.4

      \[\sqrt{2.0 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} + xre\right)}\]
    2. Using strategy rm
    3. Applied flip-+39.3

      \[\leadsto \sqrt{2.0 \cdot \color{blue}{\frac{\sqrt{xre \cdot xre + xim \cdot xim} \cdot \sqrt{xre \cdot xre + xim \cdot xim} - xre \cdot xre}{\sqrt{xre \cdot xre + xim \cdot xim} - xre}}}\]
    4. Applied associate-*r/39.3

      \[\leadsto \sqrt{\color{blue}{\frac{2.0 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} \cdot \sqrt{xre \cdot xre + xim \cdot xim} - xre \cdot xre\right)}{\sqrt{xre \cdot xre + xim \cdot xim} - xre}}}\]
    5. Applied sqrt-div39.4

      \[\leadsto \color{blue}{\frac{\sqrt{2.0 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} \cdot \sqrt{xre \cdot xre + xim \cdot xim} - xre \cdot xre\right)}}{\sqrt{\sqrt{xre \cdot xre + xim \cdot xim} - xre}}}\]
    6. Simplified28.3

      \[\leadsto \frac{\color{blue}{\sqrt{\left(xim \cdot xim + 0\right) \cdot 2.0}}}{\sqrt{\sqrt{xre \cdot xre + xim \cdot xim} - xre}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity28.3

      \[\leadsto \frac{\sqrt{\left(xim \cdot xim + 0\right) \cdot 2.0}}{\sqrt{\color{blue}{1 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} - xre\right)}}}\]
    9. Applied sqrt-prod28.3

      \[\leadsto \frac{\sqrt{\left(xim \cdot xim + 0\right) \cdot 2.0}}{\color{blue}{\sqrt{1} \cdot \sqrt{\sqrt{xre \cdot xre + xim \cdot xim} - xre}}}\]
    10. Applied sqrt-prod28.4

      \[\leadsto \frac{\color{blue}{\sqrt{xim \cdot xim + 0} \cdot \sqrt{2.0}}}{\sqrt{1} \cdot \sqrt{\sqrt{xre \cdot xre + xim \cdot xim} - xre}}\]
    11. Applied times-frac28.4

      \[\leadsto \color{blue}{\frac{\sqrt{xim \cdot xim + 0}}{\sqrt{1}} \cdot \frac{\sqrt{2.0}}{\sqrt{\sqrt{xre \cdot xre + xim \cdot xim} - xre}}}\]
    12. Simplified19.3

      \[\leadsto \color{blue}{\left|xim\right|} \cdot \frac{\sqrt{2.0}}{\sqrt{\sqrt{xre \cdot xre + xim \cdot xim} - xre}}\]

    if -3.400489128496058e-295 < xre < 1.6283846254691497e+127

    1. Initial program 20.2

      \[\sqrt{2.0 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} + xre\right)}\]

    if 1.6283846254691497e+127 < xre

    1. Initial program 54.3

      \[\sqrt{2.0 \cdot \left(\sqrt{xre \cdot xre + xim \cdot xim} + xre\right)}\]
    2. Taylor expanded around inf 8.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;xre \le -6.665919659068495 \cdot 10^{+150}:\\ \;\;\;\;\frac{\sqrt{\left(xim \cdot xim\right) \cdot 2.0}}{\sqrt{xre \cdot -2}}\\ \mathbf{elif}\;xre \le -3.400489128496058 \cdot 10^{-295}:\\ \;\;\;\;\left|xim\right| \cdot \frac{\sqrt{2.0}}{\sqrt{\sqrt{xim \cdot xim + xre \cdot xre} - xre}}\\ \mathbf{elif}\;xre \le 1.6283846254691497 \cdot 10^{+127}:\\ \;\;\;\;\sqrt{2.0 \cdot \left(\sqrt{xim \cdot xim + xre \cdot xre} + xre\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(xre + xre\right) \cdot 2.0}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (xre xim)
  :name "sqrt(2.0 * (sqrt(xre * xre + xim * xim) + xre))"
  (sqrt (* 2.0 (+ (sqrt (+ (* xre xre) (* xim xim))) xre))))