Average Error: 29.2 → 0.1
Time: 21.0s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.004873780112820976818943652375537567422725 \lor \neg \left(-2 \cdot x \le 6.018879661848789589613430844883268377998 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} \cdot {\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3} \cdot {1}^{3}}{\left(\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1\right) \cdot \left({\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} + {1}^{3}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(1 \cdot x + 1.1102230246251565404236316680908203125 \cdot 10^{-16} \cdot {x}^{4}\right) - 0.3333333333333333148296162562473909929395 \cdot {x}^{3}\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -0.004873780112820976818943652375537567422725 \lor \neg \left(-2 \cdot x \le 6.018879661848789589613430844883268377998 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} \cdot {\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3} \cdot {1}^{3}}{\left(\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1\right) \cdot \left({\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} + {1}^{3}\right)}\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r55127 = 2.0;
        double r55128 = 1.0;
        double r55129 = -2.0;
        double r55130 = x;
        double r55131 = r55129 * r55130;
        double r55132 = exp(r55131);
        double r55133 = r55128 + r55132;
        double r55134 = r55127 / r55133;
        double r55135 = r55134 - r55128;
        return r55135;
}

double f(double x, double __attribute__((unused)) y) {
        double r55136 = -2.0;
        double r55137 = x;
        double r55138 = r55136 * r55137;
        double r55139 = -0.004873780112820977;
        bool r55140 = r55138 <= r55139;
        double r55141 = 6.01887966184879e-06;
        bool r55142 = r55138 <= r55141;
        double r55143 = !r55142;
        bool r55144 = r55140 || r55143;
        double r55145 = 2.0;
        double r55146 = 1.0;
        double r55147 = exp(r55138);
        double r55148 = r55146 + r55147;
        double r55149 = r55145 / r55148;
        double r55150 = 3.0;
        double r55151 = pow(r55149, r55150);
        double r55152 = r55151 * r55151;
        double r55153 = pow(r55146, r55150);
        double r55154 = r55153 * r55153;
        double r55155 = r55152 - r55154;
        double r55156 = r55147 + r55146;
        double r55157 = r55145 / r55156;
        double r55158 = r55146 + r55157;
        double r55159 = r55157 * r55158;
        double r55160 = r55146 * r55146;
        double r55161 = r55159 + r55160;
        double r55162 = r55151 + r55153;
        double r55163 = r55161 * r55162;
        double r55164 = r55155 / r55163;
        double r55165 = r55146 * r55137;
        double r55166 = 1.1102230246251565e-16;
        double r55167 = 4.0;
        double r55168 = pow(r55137, r55167);
        double r55169 = r55166 * r55168;
        double r55170 = r55165 + r55169;
        double r55171 = 0.3333333333333333;
        double r55172 = pow(r55137, r55150);
        double r55173 = r55171 * r55172;
        double r55174 = r55170 - r55173;
        double r55175 = r55144 ? r55164 : r55174;
        return r55175;
}

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.004873780112820977 or 6.01887966184879e-06 < (* -2.0 x)

    1. Initial program 0.1

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

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

      \[\leadsto \frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3}}{\color{blue}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}}\]
    5. Using strategy rm
    6. Applied flip--0.1

      \[\leadsto \frac{\color{blue}{\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} \cdot {\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3} \cdot {1}^{3}}{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} + {1}^{3}}}}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}\]
    7. Applied associate-/l/0.1

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

    if -0.004873780112820977 < (* -2.0 x) < 6.01887966184879e-06

    1. Initial program 59.4

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

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

      \[\leadsto \frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3}}{\color{blue}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}}\]
    5. Taylor expanded around 0 0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.004873780112820976818943652375537567422725 \lor \neg \left(-2 \cdot x \le 6.018879661848789589613430844883268377998 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} \cdot {\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3} \cdot {1}^{3}}{\left(\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1\right) \cdot \left({\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} + {1}^{3}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(1 \cdot x + 1.1102230246251565404236316680908203125 \cdot 10^{-16} \cdot {x}^{4}\right) - 0.3333333333333333148296162562473909929395 \cdot {x}^{3}\\ \end{array}\]

Reproduce

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