Average Error: 28.6 → 0.1
Time: 11.0s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -10.59134336807250598155860643601045012474 \lor \neg \left(-2 \cdot x \le 2.432764789018744349367862067623491384438 \cdot 10^{-4}\right):\\ \;\;\;\;\frac{\frac{1}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}}}}{\frac{\sqrt{1 + e^{-2 \cdot x}}}{\frac{2}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}}}}} - 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -10.59134336807250598155860643601045012474 \lor \neg \left(-2 \cdot x \le 2.432764789018744349367862067623491384438 \cdot 10^{-4}\right):\\
\;\;\;\;\frac{\frac{1}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}}}}{\frac{\sqrt{1 + e^{-2 \cdot x}}}{\frac{2}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}}}}} - 1\\

\mathbf{else}:\\
\;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r57917 = 2.0;
        double r57918 = 1.0;
        double r57919 = -2.0;
        double r57920 = x;
        double r57921 = r57919 * r57920;
        double r57922 = exp(r57921);
        double r57923 = r57918 + r57922;
        double r57924 = r57917 / r57923;
        double r57925 = r57924 - r57918;
        return r57925;
}

double f(double x, double __attribute__((unused)) y) {
        double r57926 = -2.0;
        double r57927 = x;
        double r57928 = r57926 * r57927;
        double r57929 = -10.591343368072506;
        bool r57930 = r57928 <= r57929;
        double r57931 = 0.00024327647890187443;
        bool r57932 = r57928 <= r57931;
        double r57933 = !r57932;
        bool r57934 = r57930 || r57933;
        double r57935 = 1.0;
        double r57936 = 1.0;
        double r57937 = exp(r57928);
        double r57938 = r57936 + r57937;
        double r57939 = sqrt(r57938);
        double r57940 = sqrt(r57939);
        double r57941 = r57935 / r57940;
        double r57942 = 2.0;
        double r57943 = r57942 / r57940;
        double r57944 = r57939 / r57943;
        double r57945 = r57941 / r57944;
        double r57946 = r57945 - r57936;
        double r57947 = r57936 * r57927;
        double r57948 = 5.551115123125783e-17;
        double r57949 = 4.0;
        double r57950 = pow(r57927, r57949);
        double r57951 = r57948 * r57950;
        double r57952 = 0.33333333333333337;
        double r57953 = 3.0;
        double r57954 = pow(r57927, r57953);
        double r57955 = r57952 * r57954;
        double r57956 = r57951 + r57955;
        double r57957 = r57947 - r57956;
        double r57958 = r57934 ? r57946 : r57957;
        return r57958;
}

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 2 regimes
  2. if (* -2.0 x) < -10.591343368072506 or 0.00024327647890187443 < (* -2.0 x)

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.0

      \[\leadsto \frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied associate-/r*0.0

      \[\leadsto \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt0.0

      \[\leadsto \frac{\frac{2}{\sqrt{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1\]
    7. Applied sqrt-prod0.0

      \[\leadsto \frac{\frac{2}{\color{blue}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt{\sqrt{1 + e^{-2 \cdot x}}}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1\]
    8. Applied *-un-lft-identity0.0

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot 2}}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1\]
    9. Applied times-frac0.0

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}}} \cdot \frac{2}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1\]
    10. Applied associate-/l*0.0

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}}}}{\frac{\sqrt{1 + e^{-2 \cdot x}}}{\frac{2}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}}}}}} - 1\]

    if -10.591343368072506 < (* -2.0 x) < 0.00024327647890187443

    1. Initial program 59.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Taylor expanded around 0 0.2

      \[\leadsto \color{blue}{1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -10.59134336807250598155860643601045012474 \lor \neg \left(-2 \cdot x \le 2.432764789018744349367862067623491384438 \cdot 10^{-4}\right):\\ \;\;\;\;\frac{\frac{1}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}}}}{\frac{\sqrt{1 + e^{-2 \cdot x}}}{\frac{2}{\sqrt{\sqrt{1 + e^{-2 \cdot x}}}}}} - 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019322 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  :precision binary64
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))