Average Error: 29.2 → 0.2
Time: 14.1s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -30.01217653759367109955746855121105909348 \lor \neg \left(-2 \cdot x \le 1.928362974497356761681291295595919166317 \cdot 10^{-6}\right):\\ \;\;\;\;\sqrt[3]{{\left(\frac{2}{e^{-2 \cdot x} + 1}\right)}^{3}} - 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -30.01217653759367109955746855121105909348 \lor \neg \left(-2 \cdot x \le 1.928362974497356761681291295595919166317 \cdot 10^{-6}\right):\\
\;\;\;\;\sqrt[3]{{\left(\frac{2}{e^{-2 \cdot x} + 1}\right)}^{3}} - 1\\

\mathbf{else}:\\
\;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r28047 = 2.0;
        double r28048 = 1.0;
        double r28049 = -2.0;
        double r28050 = x;
        double r28051 = r28049 * r28050;
        double r28052 = exp(r28051);
        double r28053 = r28048 + r28052;
        double r28054 = r28047 / r28053;
        double r28055 = r28054 - r28048;
        return r28055;
}

double f(double x, double __attribute__((unused)) y) {
        double r28056 = -2.0;
        double r28057 = x;
        double r28058 = r28056 * r28057;
        double r28059 = -30.01217653759367;
        bool r28060 = r28058 <= r28059;
        double r28061 = 1.9283629744973568e-06;
        bool r28062 = r28058 <= r28061;
        double r28063 = !r28062;
        bool r28064 = r28060 || r28063;
        double r28065 = 2.0;
        double r28066 = exp(r28058);
        double r28067 = 1.0;
        double r28068 = r28066 + r28067;
        double r28069 = r28065 / r28068;
        double r28070 = 3.0;
        double r28071 = pow(r28069, r28070);
        double r28072 = cbrt(r28071);
        double r28073 = r28072 - r28067;
        double r28074 = r28067 * r28057;
        double r28075 = 5.551115123125783e-17;
        double r28076 = 4.0;
        double r28077 = pow(r28057, r28076);
        double r28078 = r28075 * r28077;
        double r28079 = 0.33333333333333337;
        double r28080 = pow(r28057, r28070);
        double r28081 = r28079 * r28080;
        double r28082 = r28078 + r28081;
        double r28083 = r28074 - r28082;
        double r28084 = r28064 ? r28073 : r28083;
        return r28084;
}

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) < -30.01217653759367 or 1.9283629744973568e-06 < (* -2.0 x)

    1. Initial program 0.1

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

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

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(2 \cdot 2\right) \cdot 2}}}{\sqrt[3]{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \left(1 + e^{-2 \cdot x}\right)\right) \cdot \left(1 + e^{-2 \cdot x}\right)}} - 1\]
    5. Applied cbrt-undiv0.1

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

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

    if -30.01217653759367 < (* -2.0 x) < 1.9283629744973568e-06

    1. Initial program 59.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -30.01217653759367109955746855121105909348 \lor \neg \left(-2 \cdot x \le 1.928362974497356761681291295595919166317 \cdot 10^{-6}\right):\\ \;\;\;\;\sqrt[3]{{\left(\frac{2}{e^{-2 \cdot x} + 1}\right)}^{3}} - 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\ \end{array}\]

Reproduce

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