Average Error: 38.6 → 18.6
Time: 10.8s
Precision: 64
\[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} + sre\right)}\]
\[\begin{array}{l} \mathbf{if}\;sre \le -5.369633668174498803459642934039108441214 \cdot 10^{137}:\\ \;\;\;\;\frac{\sqrt{\left(xim \cdot xim\right) \cdot 2}}{\sqrt{\left(-sre\right) - sre}} \cdot 0.5\\ \mathbf{elif}\;sre \le -3.532234512109790750132422957206188388696 \cdot 10^{-296}:\\ \;\;\;\;0.5 \cdot \frac{\sqrt{2}}{\frac{\sqrt{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}{\left|xim\right|}}\\ \mathbf{elif}\;sre \le 4.944794961514355427000939408494111733969 \cdot 10^{128}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} + sre\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(2 \cdot sre\right)}\\ \end{array}\]
0.5 \cdot \sqrt{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} + sre\right)}
\begin{array}{l}
\mathbf{if}\;sre \le -5.369633668174498803459642934039108441214 \cdot 10^{137}:\\
\;\;\;\;\frac{\sqrt{\left(xim \cdot xim\right) \cdot 2}}{\sqrt{\left(-sre\right) - sre}} \cdot 0.5\\

\mathbf{elif}\;sre \le -3.532234512109790750132422957206188388696 \cdot 10^{-296}:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{2}}{\frac{\sqrt{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}{\left|xim\right|}}\\

\mathbf{elif}\;sre \le 4.944794961514355427000939408494111733969 \cdot 10^{128}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} + sre\right)}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(2 \cdot sre\right)}\\

\end{array}
double f(double sre, double xim) {
        double r1642754 = 0.5;
        double r1642755 = 2.0;
        double r1642756 = sre;
        double r1642757 = r1642756 * r1642756;
        double r1642758 = xim;
        double r1642759 = r1642758 * r1642758;
        double r1642760 = r1642757 + r1642759;
        double r1642761 = sqrt(r1642760);
        double r1642762 = r1642761 + r1642756;
        double r1642763 = r1642755 * r1642762;
        double r1642764 = sqrt(r1642763);
        double r1642765 = r1642754 * r1642764;
        return r1642765;
}

double f(double sre, double xim) {
        double r1642766 = sre;
        double r1642767 = -5.369633668174499e+137;
        bool r1642768 = r1642766 <= r1642767;
        double r1642769 = xim;
        double r1642770 = r1642769 * r1642769;
        double r1642771 = 2.0;
        double r1642772 = r1642770 * r1642771;
        double r1642773 = sqrt(r1642772);
        double r1642774 = -r1642766;
        double r1642775 = r1642774 - r1642766;
        double r1642776 = sqrt(r1642775);
        double r1642777 = r1642773 / r1642776;
        double r1642778 = 0.5;
        double r1642779 = r1642777 * r1642778;
        double r1642780 = -3.532234512109791e-296;
        bool r1642781 = r1642766 <= r1642780;
        double r1642782 = sqrt(r1642771);
        double r1642783 = r1642766 * r1642766;
        double r1642784 = r1642783 + r1642770;
        double r1642785 = sqrt(r1642784);
        double r1642786 = r1642785 - r1642766;
        double r1642787 = sqrt(r1642786);
        double r1642788 = fabs(r1642769);
        double r1642789 = r1642787 / r1642788;
        double r1642790 = r1642782 / r1642789;
        double r1642791 = r1642778 * r1642790;
        double r1642792 = 4.9447949615143554e+128;
        bool r1642793 = r1642766 <= r1642792;
        double r1642794 = r1642785 + r1642766;
        double r1642795 = r1642771 * r1642794;
        double r1642796 = sqrt(r1642795);
        double r1642797 = r1642778 * r1642796;
        double r1642798 = 2.0;
        double r1642799 = r1642798 * r1642766;
        double r1642800 = r1642771 * r1642799;
        double r1642801 = sqrt(r1642800);
        double r1642802 = r1642778 * r1642801;
        double r1642803 = r1642793 ? r1642797 : r1642802;
        double r1642804 = r1642781 ? r1642791 : r1642803;
        double r1642805 = r1642768 ? r1642779 : r1642804;
        return r1642805;
}

Error

Bits error versus sre

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 sre < -5.369633668174499e+137

    1. Initial program 62.9

      \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} + sre\right)}\]
    2. Using strategy rm
    3. Applied flip-+62.9

      \[\leadsto 0.5 \cdot \sqrt{2 \cdot \color{blue}{\frac{\sqrt{sre \cdot sre + xim \cdot xim} \cdot \sqrt{sre \cdot sre + xim \cdot xim} - sre \cdot sre}{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}}\]
    4. Applied associate-*r/62.9

      \[\leadsto 0.5 \cdot \sqrt{\color{blue}{\frac{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} \cdot \sqrt{sre \cdot sre + xim \cdot xim} - sre \cdot sre\right)}{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}}\]
    5. Applied sqrt-div62.9

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\sqrt{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} \cdot \sqrt{sre \cdot sre + xim \cdot xim} - sre \cdot sre\right)}}{\sqrt{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}}\]
    6. Simplified47.1

      \[\leadsto 0.5 \cdot \frac{\color{blue}{\sqrt{2 \cdot \left(xim \cdot xim + 0\right)}}}{\sqrt{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}\]
    7. Taylor expanded around -inf 21.1

      \[\leadsto 0.5 \cdot \frac{\sqrt{2 \cdot \left(xim \cdot xim + 0\right)}}{\sqrt{\color{blue}{-1 \cdot sre} - sre}}\]
    8. Simplified21.1

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

    if -5.369633668174499e+137 < sre < -3.532234512109791e-296

    1. Initial program 39.7

      \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} + sre\right)}\]
    2. Using strategy rm
    3. Applied flip-+39.4

      \[\leadsto 0.5 \cdot \sqrt{2 \cdot \color{blue}{\frac{\sqrt{sre \cdot sre + xim \cdot xim} \cdot \sqrt{sre \cdot sre + xim \cdot xim} - sre \cdot sre}{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}}\]
    4. Applied associate-*r/39.4

      \[\leadsto 0.5 \cdot \sqrt{\color{blue}{\frac{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} \cdot \sqrt{sre \cdot sre + xim \cdot xim} - sre \cdot sre\right)}{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}}\]
    5. Applied sqrt-div39.6

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\sqrt{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} \cdot \sqrt{sre \cdot sre + xim \cdot xim} - sre \cdot sre\right)}}{\sqrt{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}}\]
    6. Simplified29.2

      \[\leadsto 0.5 \cdot \frac{\color{blue}{\sqrt{2 \cdot \left(xim \cdot xim + 0\right)}}}{\sqrt{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}\]
    7. Using strategy rm
    8. Applied sqrt-prod29.2

      \[\leadsto 0.5 \cdot \frac{\color{blue}{\sqrt{2} \cdot \sqrt{xim \cdot xim + 0}}}{\sqrt{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}\]
    9. Applied associate-/l*29.2

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\sqrt{2}}{\frac{\sqrt{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}{\sqrt{xim \cdot xim + 0}}}}\]
    10. Simplified19.7

      \[\leadsto 0.5 \cdot \frac{\sqrt{2}}{\color{blue}{\frac{\sqrt{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}{\left|xim\right|}}}\]

    if -3.532234512109791e-296 < sre < 4.9447949615143554e+128

    1. Initial program 20.8

      \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} + sre\right)}\]

    if 4.9447949615143554e+128 < sre

    1. Initial program 57.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;sre \le -5.369633668174498803459642934039108441214 \cdot 10^{137}:\\ \;\;\;\;\frac{\sqrt{\left(xim \cdot xim\right) \cdot 2}}{\sqrt{\left(-sre\right) - sre}} \cdot 0.5\\ \mathbf{elif}\;sre \le -3.532234512109790750132422957206188388696 \cdot 10^{-296}:\\ \;\;\;\;0.5 \cdot \frac{\sqrt{2}}{\frac{\sqrt{\sqrt{sre \cdot sre + xim \cdot xim} - sre}}{\left|xim\right|}}\\ \mathbf{elif}\;sre \le 4.944794961514355427000939408494111733969 \cdot 10^{128}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{sre \cdot sre + xim \cdot xim} + sre\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(2 \cdot sre\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (sre xim)
  :name "0.5*sqrt(2.0*(sqrt(sre*sre+xim*xim)+sre))"
  :precision binary64
  (* 0.5 (sqrt (* 2 (+ (sqrt (+ (* sre sre) (* xim xim))) sre)))))