Average Error: 28.8 → 0.0
Time: 17.9s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.00838956395365049:\\ \;\;\;\;\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)\\ \mathbf{elif}\;x \le 0.006998885945432241:\\ \;\;\;\;\left(\frac{-1}{3} \cdot \left(x \cdot \left(x \cdot x\right)\right) + {x}^{5} \cdot \frac{2}{15}\right) + x\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;x \le -0.00838956395365049:\\
\;\;\;\;\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)\\

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

\mathbf{else}:\\
\;\;\;\;\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r1865483 = 2.0;
        double r1865484 = 1.0;
        double r1865485 = -2.0;
        double r1865486 = x;
        double r1865487 = r1865485 * r1865486;
        double r1865488 = exp(r1865487);
        double r1865489 = r1865484 + r1865488;
        double r1865490 = r1865483 / r1865489;
        double r1865491 = r1865490 - r1865484;
        return r1865491;
}

double f(double x, double __attribute__((unused)) y) {
        double r1865492 = x;
        double r1865493 = -0.00838956395365049;
        bool r1865494 = r1865492 <= r1865493;
        double r1865495 = 2.0;
        double r1865496 = -2.0;
        double r1865497 = r1865496 * r1865492;
        double r1865498 = exp(r1865497);
        double r1865499 = 1.0;
        double r1865500 = r1865498 + r1865499;
        double r1865501 = r1865495 / r1865500;
        double r1865502 = r1865501 - r1865499;
        double r1865503 = exp(r1865502);
        double r1865504 = log(r1865503);
        double r1865505 = 0.006998885945432241;
        bool r1865506 = r1865492 <= r1865505;
        double r1865507 = -0.3333333333333333;
        double r1865508 = r1865492 * r1865492;
        double r1865509 = r1865492 * r1865508;
        double r1865510 = r1865507 * r1865509;
        double r1865511 = 5.0;
        double r1865512 = pow(r1865492, r1865511);
        double r1865513 = 0.13333333333333333;
        double r1865514 = r1865512 * r1865513;
        double r1865515 = r1865510 + r1865514;
        double r1865516 = r1865515 + r1865492;
        double r1865517 = r1865506 ? r1865516 : r1865504;
        double r1865518 = r1865494 ? r1865504 : r1865517;
        return r1865518;
}

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 x < -0.00838956395365049 or 0.006998885945432241 < x

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied add-log-exp0.0

      \[\leadsto \frac{2}{1 + e^{-2 \cdot x}} - \color{blue}{\log \left(e^{1}\right)}\]
    4. Applied add-log-exp0.0

      \[\leadsto \color{blue}{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}}}\right)} - \log \left(e^{1}\right)\]
    5. Applied diff-log0.0

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

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

    if -0.00838956395365049 < x < 0.006998885945432241

    1. Initial program 59.0

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

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

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

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

Reproduce

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