Average Error: 29.6 → 0.1
Time: 35.2s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -83.20148025804453:\\ \;\;\;\;\frac{2}{e^{-2 \cdot x} + 1} - 1\\ \mathbf{elif}\;-2 \cdot x \le 3.58822878881946 \cdot 10^{-05}:\\ \;\;\;\;\left({x}^{5} \cdot \frac{2}{15} + \left(x \cdot x\right) \cdot \left(x \cdot \frac{-1}{3}\right)\right) + x\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{e^{-2 \cdot x} + 1} - 1\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -83.20148025804453:\\
\;\;\;\;\frac{2}{e^{-2 \cdot x} + 1} - 1\\

\mathbf{elif}\;-2 \cdot x \le 3.58822878881946 \cdot 10^{-05}:\\
\;\;\;\;\left({x}^{5} \cdot \frac{2}{15} + \left(x \cdot x\right) \cdot \left(x \cdot \frac{-1}{3}\right)\right) + x\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{e^{-2 \cdot x} + 1} - 1\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r1880115 = 2.0;
        double r1880116 = 1.0;
        double r1880117 = -2.0;
        double r1880118 = x;
        double r1880119 = r1880117 * r1880118;
        double r1880120 = exp(r1880119);
        double r1880121 = r1880116 + r1880120;
        double r1880122 = r1880115 / r1880121;
        double r1880123 = r1880122 - r1880116;
        return r1880123;
}

double f(double x, double __attribute__((unused)) y) {
        double r1880124 = -2.0;
        double r1880125 = x;
        double r1880126 = r1880124 * r1880125;
        double r1880127 = -83.20148025804453;
        bool r1880128 = r1880126 <= r1880127;
        double r1880129 = 2.0;
        double r1880130 = exp(r1880126);
        double r1880131 = 1.0;
        double r1880132 = r1880130 + r1880131;
        double r1880133 = r1880129 / r1880132;
        double r1880134 = r1880133 - r1880131;
        double r1880135 = 3.58822878881946e-05;
        bool r1880136 = r1880126 <= r1880135;
        double r1880137 = 5.0;
        double r1880138 = pow(r1880125, r1880137);
        double r1880139 = 0.13333333333333333;
        double r1880140 = r1880138 * r1880139;
        double r1880141 = r1880125 * r1880125;
        double r1880142 = -0.3333333333333333;
        double r1880143 = r1880125 * r1880142;
        double r1880144 = r1880141 * r1880143;
        double r1880145 = r1880140 + r1880144;
        double r1880146 = r1880145 + r1880125;
        double r1880147 = r1880136 ? r1880146 : r1880134;
        double r1880148 = r1880128 ? r1880134 : r1880147;
        return r1880148;
}

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 x) < -83.20148025804453 or 3.58822878881946e-05 < (* -2 x)

    1. Initial program 0.1

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

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

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

    if -83.20148025804453 < (* -2 x) < 3.58822878881946e-05

    1. Initial program 59.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -83.20148025804453:\\ \;\;\;\;\frac{2}{e^{-2 \cdot x} + 1} - 1\\ \mathbf{elif}\;-2 \cdot x \le 3.58822878881946 \cdot 10^{-05}:\\ \;\;\;\;\left({x}^{5} \cdot \frac{2}{15} + \left(x \cdot x\right) \cdot \left(x \cdot \frac{-1}{3}\right)\right) + x\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{e^{-2 \cdot x} + 1} - 1\\ \end{array}\]

Reproduce

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