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

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

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r2120550 = 2.0;
        double r2120551 = 1.0;
        double r2120552 = -2.0;
        double r2120553 = x;
        double r2120554 = r2120552 * r2120553;
        double r2120555 = exp(r2120554);
        double r2120556 = r2120551 + r2120555;
        double r2120557 = r2120550 / r2120556;
        double r2120558 = r2120557 - r2120551;
        return r2120558;
}

double f(double x, double __attribute__((unused)) y) {
        double r2120559 = x;
        double r2120560 = -0.007801985501095653;
        bool r2120561 = r2120559 <= r2120560;
        double r2120562 = 2.0;
        double r2120563 = 1.0;
        double r2120564 = -2.0;
        double r2120565 = r2120564 * r2120559;
        double r2120566 = exp(r2120565);
        double r2120567 = r2120563 + r2120566;
        double r2120568 = r2120562 / r2120567;
        double r2120569 = r2120568 - r2120563;
        double r2120570 = 0.007393742180593579;
        bool r2120571 = r2120559 <= r2120570;
        double r2120572 = 5.0;
        double r2120573 = pow(r2120559, r2120572);
        double r2120574 = 0.13333333333333333;
        double r2120575 = r2120573 * r2120574;
        double r2120576 = -0.3333333333333333;
        double r2120577 = r2120559 * r2120559;
        double r2120578 = r2120559 * r2120577;
        double r2120579 = r2120576 * r2120578;
        double r2120580 = r2120575 + r2120579;
        double r2120581 = r2120559 + r2120580;
        double r2120582 = r2120565 + r2120565;
        double r2120583 = r2120582 + r2120565;
        double r2120584 = exp(r2120583);
        double r2120585 = r2120563 + r2120584;
        double r2120586 = r2120562 / r2120585;
        double r2120587 = r2120566 * r2120566;
        double r2120588 = r2120587 - r2120566;
        double r2120589 = r2120563 + r2120588;
        double r2120590 = r2120586 * r2120589;
        double r2120591 = r2120590 - r2120563;
        double r2120592 = r2120571 ? r2120581 : r2120591;
        double r2120593 = r2120561 ? r2120569 : r2120592;
        return r2120593;
}

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 3 regimes
  2. if x < -0.007801985501095653

    1. Initial program 0.0

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

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

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

    if -0.007801985501095653 < x < 0.007393742180593579

    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)}\]

    if 0.007393742180593579 < x

    1. Initial program 0.0

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

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

      \[\leadsto \color{blue}{\frac{2}{1 + e^{x \cdot -2}} - 1}\]
    4. Using strategy rm
    5. Applied flip3-+0.0

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

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

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

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

Reproduce

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