Average Error: 29.8 → 0.1
Time: 5.6s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.8755191573179796904469185392372310161591:\\ \;\;\;\;\frac{\frac{1}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}} \cdot \frac{2}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1\\ \mathbf{elif}\;-2 \cdot x \le 0.001318496133275824351918648069670325639891:\\ \;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1} \cdot \sqrt[3]{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1}\right) \cdot \sqrt[3]{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{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 -0.8755191573179796904469185392372310161591:\\
\;\;\;\;\frac{\frac{1}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}} \cdot \frac{2}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1\\

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

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r58714 = 2.0;
        double r58715 = 1.0;
        double r58716 = -2.0;
        double r58717 = x;
        double r58718 = r58716 * r58717;
        double r58719 = exp(r58718);
        double r58720 = r58715 + r58719;
        double r58721 = r58714 / r58720;
        double r58722 = r58721 - r58715;
        return r58722;
}

double f(double x, double __attribute__((unused)) y) {
        double r58723 = -2.0;
        double r58724 = x;
        double r58725 = r58723 * r58724;
        double r58726 = -0.8755191573179797;
        bool r58727 = r58725 <= r58726;
        double r58728 = 1.0;
        double r58729 = 1.0;
        double r58730 = exp(r58725);
        double r58731 = r58729 + r58730;
        double r58732 = sqrt(r58731);
        double r58733 = cbrt(r58732);
        double r58734 = r58733 * r58733;
        double r58735 = r58728 / r58734;
        double r58736 = 2.0;
        double r58737 = r58736 / r58733;
        double r58738 = r58735 * r58737;
        double r58739 = r58738 / r58732;
        double r58740 = r58739 - r58729;
        double r58741 = 0.0013184961332758244;
        bool r58742 = r58725 <= r58741;
        double r58743 = r58729 * r58724;
        double r58744 = 5.551115123125783e-17;
        double r58745 = 4.0;
        double r58746 = pow(r58724, r58745);
        double r58747 = r58744 * r58746;
        double r58748 = 0.33333333333333337;
        double r58749 = 3.0;
        double r58750 = pow(r58724, r58749);
        double r58751 = r58748 * r58750;
        double r58752 = r58747 + r58751;
        double r58753 = r58743 - r58752;
        double r58754 = r58736 / r58732;
        double r58755 = r58754 / r58732;
        double r58756 = r58755 - r58729;
        double r58757 = cbrt(r58756);
        double r58758 = r58757 * r58757;
        double r58759 = r58758 * r58757;
        double r58760 = r58742 ? r58753 : r58759;
        double r58761 = r58727 ? r58740 : r58760;
        return r58761;
}

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 (* -2.0 x) < -0.8755191573179797

    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\]
    5. Using strategy rm
    6. Applied add-cube-cbrt0.0

      \[\leadsto \frac{\frac{2}{\color{blue}{\left(\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}\right) \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1\]
    7. Applied *-un-lft-identity0.0

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot 2}}{\left(\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}\right) \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1\]
    8. Applied times-frac0.0

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

    if -0.8755191573179797 < (* -2.0 x) < 0.0013184961332758244

    1. Initial program 59.1

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

      \[\leadsto \color{blue}{1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)}\]

    if 0.0013184961332758244 < (* -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.1

      \[\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\]
    5. Using strategy rm
    6. Applied add-cube-cbrt0.1

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

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

Reproduce

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