Average Error: 29.1 → 0.4
Time: 11.3s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -6563741.316988286562263965606689453125 \lor \neg \left(-2 \cdot x \le 5.855217900651384679540714661705180787976 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 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 -6563741.316988286562263965606689453125 \lor \neg \left(-2 \cdot x \le 5.855217900651384679540714661705180787976 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 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 r38736 = 2.0;
        double r38737 = 1.0;
        double r38738 = -2.0;
        double r38739 = x;
        double r38740 = r38738 * r38739;
        double r38741 = exp(r38740);
        double r38742 = r38737 + r38741;
        double r38743 = r38736 / r38742;
        double r38744 = r38743 - r38737;
        return r38744;
}

double f(double x, double __attribute__((unused)) y) {
        double r38745 = -2.0;
        double r38746 = x;
        double r38747 = r38745 * r38746;
        double r38748 = -6563741.316988287;
        bool r38749 = r38747 <= r38748;
        double r38750 = 5.855217900651385e-05;
        bool r38751 = r38747 <= r38750;
        double r38752 = !r38751;
        bool r38753 = r38749 || r38752;
        double r38754 = 2.0;
        double r38755 = 1.0;
        double r38756 = exp(r38747);
        double r38757 = r38755 + r38756;
        double r38758 = sqrt(r38757);
        double r38759 = r38754 / r38758;
        double r38760 = r38759 / r38758;
        double r38761 = r38760 - r38755;
        double r38762 = r38755 * r38746;
        double r38763 = 5.551115123125783e-17;
        double r38764 = 4.0;
        double r38765 = pow(r38746, r38764);
        double r38766 = r38763 * r38765;
        double r38767 = 0.33333333333333337;
        double r38768 = 3.0;
        double r38769 = pow(r38746, r38768);
        double r38770 = r38767 * r38769;
        double r38771 = r38766 + r38770;
        double r38772 = r38762 - r38771;
        double r38773 = r38753 ? r38761 : r38772;
        return r38773;
}

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) < -6563741.316988287 or 5.855217900651385e-05 < (* -2.0 x)

    1. Initial program 0.0

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

      \[\leadsto \frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied associate-/r*0.0

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

    if -6563741.316988287 < (* -2.0 x) < 5.855217900651385e-05

    1. Initial program 58.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -6563741.316988286562263965606689453125 \lor \neg \left(-2 \cdot x \le 5.855217900651384679540714661705180787976 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 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 2019298 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  :precision binary64
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))