Average Error: 29.1 → 0.4
Time: 11.7s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -10.441546109821596:\\ \;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} - 1\\ \mathbf{elif}\;-2 \cdot x \le 3.5757785930510215 \cdot 10^{-15}:\\ \;\;\;\;\left({x}^{5} \cdot \frac{2}{15} + \frac{-1}{3} \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) + x\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} - 1\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -10.441546109821596:\\
\;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} - 1\\

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

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r2750708 = 2.0;
        double r2750709 = 1.0;
        double r2750710 = -2.0;
        double r2750711 = x;
        double r2750712 = r2750710 * r2750711;
        double r2750713 = exp(r2750712);
        double r2750714 = r2750709 + r2750713;
        double r2750715 = r2750708 / r2750714;
        double r2750716 = r2750715 - r2750709;
        return r2750716;
}

double f(double x, double __attribute__((unused)) y) {
        double r2750717 = -2.0;
        double r2750718 = x;
        double r2750719 = r2750717 * r2750718;
        double r2750720 = -10.441546109821596;
        bool r2750721 = r2750719 <= r2750720;
        double r2750722 = 2.0;
        double r2750723 = 1.0;
        double r2750724 = exp(r2750719);
        double r2750725 = r2750723 + r2750724;
        double r2750726 = r2750722 / r2750725;
        double r2750727 = r2750726 - r2750723;
        double r2750728 = 3.5757785930510215e-15;
        bool r2750729 = r2750719 <= r2750728;
        double r2750730 = 5.0;
        double r2750731 = pow(r2750718, r2750730);
        double r2750732 = 0.13333333333333333;
        double r2750733 = r2750731 * r2750732;
        double r2750734 = -0.3333333333333333;
        double r2750735 = r2750718 * r2750718;
        double r2750736 = r2750718 * r2750735;
        double r2750737 = r2750734 * r2750736;
        double r2750738 = r2750733 + r2750737;
        double r2750739 = r2750738 + r2750718;
        double r2750740 = r2750729 ? r2750739 : r2750727;
        double r2750741 = r2750721 ? r2750727 : r2750740;
        return r2750741;
}

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) < -10.441546109821596 or 3.5757785930510215e-15 < (* -2 x)

    1. Initial program 0.6

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

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

    if -10.441546109821596 < (* -2 x) < 3.5757785930510215e-15

    1. Initial program 59.4

      \[\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}{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.4

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

Reproduce

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