Average Error: 28.8 → 0.5
Time: 11.6s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -4690010.71037716139 \lor \neg \left(-2 \cdot x \le 3.2942790551493054 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -4690010.71037716139 \lor \neg \left(-2 \cdot x \le 3.2942790551493054 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r47901 = 2.0;
        double r47902 = 1.0;
        double r47903 = -2.0;
        double r47904 = x;
        double r47905 = r47903 * r47904;
        double r47906 = exp(r47905);
        double r47907 = r47902 + r47906;
        double r47908 = r47901 / r47907;
        double r47909 = r47908 - r47902;
        return r47909;
}

double f(double x, double __attribute__((unused)) y) {
        double r47910 = -2.0;
        double r47911 = x;
        double r47912 = r47910 * r47911;
        double r47913 = -4690010.710377161;
        bool r47914 = r47912 <= r47913;
        double r47915 = 3.2942790551493054e-05;
        bool r47916 = r47912 <= r47915;
        double r47917 = !r47916;
        bool r47918 = r47914 || r47917;
        double r47919 = 2.0;
        double r47920 = 1.0;
        double r47921 = exp(r47912);
        double r47922 = r47920 + r47921;
        double r47923 = sqrt(r47922);
        double r47924 = r47919 / r47923;
        double r47925 = r47924 / r47923;
        double r47926 = r47925 - r47920;
        double r47927 = r47920 * r47911;
        double r47928 = 5.551115123125783e-17;
        double r47929 = 4.0;
        double r47930 = pow(r47911, r47929);
        double r47931 = r47928 * r47930;
        double r47932 = 0.33333333333333337;
        double r47933 = 3.0;
        double r47934 = pow(r47911, r47933);
        double r47935 = r47932 * r47934;
        double r47936 = r47931 + r47935;
        double r47937 = r47927 - r47936;
        double r47938 = r47918 ? r47926 : r47937;
        return r47938;
}

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) < -4690010.710377161 or 3.2942790551493054e-05 < (* -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.1

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

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

    if -4690010.710377161 < (* -2.0 x) < 3.2942790551493054e-05

    1. Initial program 58.5

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

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

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

Reproduce

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