Average Error: 29.0 → 0.1
Time: 11.6s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.16694293117624887 \lor \neg \left(-2 \cdot x \le 1.3471487435038969 \cdot 10^{-8}\right):\\ \;\;\;\;\left(\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1\right) \cdot \frac{1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(4.996 \cdot 10^{-16} \cdot {x}^{4} + 0.33333333333333348 \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -0.16694293117624887 \lor \neg \left(-2 \cdot x \le 1.3471487435038969 \cdot 10^{-8}\right):\\
\;\;\;\;\left(\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1\right) \cdot \frac{1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot x - \left(4.996 \cdot 10^{-16} \cdot {x}^{4} + 0.33333333333333348 \cdot {x}^{3}\right)\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r55863 = 2.0;
        double r55864 = 1.0;
        double r55865 = -2.0;
        double r55866 = x;
        double r55867 = r55865 * r55866;
        double r55868 = exp(r55867);
        double r55869 = r55864 + r55868;
        double r55870 = r55863 / r55869;
        double r55871 = r55870 - r55864;
        return r55871;
}

double f(double x, double __attribute__((unused)) y) {
        double r55872 = -2.0;
        double r55873 = x;
        double r55874 = r55872 * r55873;
        double r55875 = -0.16694293117624887;
        bool r55876 = r55874 <= r55875;
        double r55877 = 1.3471487435038969e-08;
        bool r55878 = r55874 <= r55877;
        double r55879 = !r55878;
        bool r55880 = r55876 || r55879;
        double r55881 = 2.0;
        double r55882 = 1.0;
        double r55883 = exp(r55874);
        double r55884 = r55882 + r55883;
        double r55885 = r55881 / r55884;
        double r55886 = r55885 * r55885;
        double r55887 = r55882 * r55882;
        double r55888 = r55886 - r55887;
        double r55889 = 1.0;
        double r55890 = r55885 + r55882;
        double r55891 = r55889 / r55890;
        double r55892 = r55888 * r55891;
        double r55893 = r55882 * r55873;
        double r55894 = 4.996003610813204e-16;
        double r55895 = 4.0;
        double r55896 = pow(r55873, r55895);
        double r55897 = r55894 * r55896;
        double r55898 = 0.3333333333333335;
        double r55899 = 3.0;
        double r55900 = pow(r55873, r55899);
        double r55901 = r55898 * r55900;
        double r55902 = r55897 + r55901;
        double r55903 = r55893 - r55902;
        double r55904 = r55880 ? r55892 : r55903;
        return r55904;
}

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) < -0.16694293117624887 or 1.3471487435038969e-08 < (* -2.0 x)

    1. Initial program 0.2

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied flip--0.2

      \[\leadsto \color{blue}{\frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}}\]
    4. Using strategy rm
    5. Applied div-inv0.2

      \[\leadsto \color{blue}{\left(\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1\right) \cdot \frac{1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}}\]

    if -0.16694293117624887 < (* -2.0 x) < 1.3471487435038969e-08

    1. Initial program 59.4

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied flip--59.4

      \[\leadsto \color{blue}{\frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}}\]
    4. Taylor expanded around 0 0.1

      \[\leadsto \color{blue}{1 \cdot x - \left(4.996 \cdot 10^{-16} \cdot {x}^{4} + 0.33333333333333348 \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 -0.16694293117624887 \lor \neg \left(-2 \cdot x \le 1.3471487435038969 \cdot 10^{-8}\right):\\ \;\;\;\;\left(\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1\right) \cdot \frac{1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(4.996 \cdot 10^{-16} \cdot {x}^{4} + 0.33333333333333348 \cdot {x}^{3}\right)\\ \end{array}\]

Reproduce

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