Average Error: 29.0 → 0.1
Time: 13.9s
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(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 -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(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 r63099 = 2.0;
        double r63100 = 1.0;
        double r63101 = -2.0;
        double r63102 = x;
        double r63103 = r63101 * r63102;
        double r63104 = exp(r63103);
        double r63105 = r63100 + r63104;
        double r63106 = r63099 / r63105;
        double r63107 = r63106 - r63100;
        return r63107;
}

double f(double x, double __attribute__((unused)) y) {
        double r63108 = -2.0;
        double r63109 = x;
        double r63110 = r63108 * r63109;
        double r63111 = -0.16694293117624887;
        bool r63112 = r63110 <= r63111;
        double r63113 = 1.3471487435038969e-08;
        bool r63114 = r63110 <= r63113;
        double r63115 = !r63114;
        bool r63116 = r63112 || r63115;
        double r63117 = 2.0;
        double r63118 = 1.0;
        double r63119 = exp(r63110);
        double r63120 = r63118 + r63119;
        double r63121 = r63117 / r63120;
        double r63122 = r63121 * r63121;
        double r63123 = r63118 * r63118;
        double r63124 = r63122 - r63123;
        double r63125 = 1.0;
        double r63126 = r63121 + r63118;
        double r63127 = r63125 / r63126;
        double r63128 = r63124 * r63127;
        double r63129 = r63118 * r63109;
        double r63130 = 5.551115123125783e-17;
        double r63131 = 4.0;
        double r63132 = pow(r63109, r63131);
        double r63133 = r63130 * r63132;
        double r63134 = 0.33333333333333337;
        double r63135 = 3.0;
        double r63136 = pow(r63109, r63135);
        double r63137 = r63134 * r63136;
        double r63138 = r63133 + r63137;
        double r63139 = r63129 - r63138;
        double r63140 = r63116 ? r63128 : r63139;
        return r63140;
}

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. Taylor expanded around 0 0.1

      \[\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.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(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \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))