Average Error: 29.4 → 0.2
Time: 3.1s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -43.320057343176309 \lor \neg \left(-2 \cdot x \le 1.0366643272928921 \cdot 10^{-5}\right):\\ \;\;\;\;\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right) + \log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -43.320057343176309 \lor \neg \left(-2 \cdot x \le 1.0366643272928921 \cdot 10^{-5}\right):\\
\;\;\;\;\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right) + \log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r49770 = 2.0;
        double r49771 = 1.0;
        double r49772 = -2.0;
        double r49773 = x;
        double r49774 = r49772 * r49773;
        double r49775 = exp(r49774);
        double r49776 = r49771 + r49775;
        double r49777 = r49770 / r49776;
        double r49778 = r49777 - r49771;
        return r49778;
}

double f(double x, double __attribute__((unused)) y) {
        double r49779 = -2.0;
        double r49780 = x;
        double r49781 = r49779 * r49780;
        double r49782 = -43.32005734317631;
        bool r49783 = r49781 <= r49782;
        double r49784 = 1.0366643272928921e-05;
        bool r49785 = r49781 <= r49784;
        double r49786 = !r49785;
        bool r49787 = r49783 || r49786;
        double r49788 = 2.0;
        double r49789 = 1.0;
        double r49790 = exp(r49781);
        double r49791 = r49789 + r49790;
        double r49792 = r49788 / r49791;
        double r49793 = r49792 - r49789;
        double r49794 = exp(r49793);
        double r49795 = sqrt(r49794);
        double r49796 = log(r49795);
        double r49797 = r49796 + r49796;
        double r49798 = r49789 * r49780;
        double r49799 = 5.551115123125783e-17;
        double r49800 = 4.0;
        double r49801 = pow(r49780, r49800);
        double r49802 = r49799 * r49801;
        double r49803 = 0.33333333333333337;
        double r49804 = 3.0;
        double r49805 = pow(r49780, r49804);
        double r49806 = r49803 * r49805;
        double r49807 = r49802 + r49806;
        double r49808 = r49798 - r49807;
        double r49809 = r49787 ? r49797 : r49808;
        return r49809;
}

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

    1. Initial program 0.1

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

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

      \[\leadsto \color{blue}{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}}}\right)} - \log \left(e^{1}\right)\]
    5. Applied diff-log0.1

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

      \[\leadsto \log \color{blue}{\left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt0.1

      \[\leadsto \log \color{blue}{\left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}} \cdot \sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)}\]
    9. Applied log-prod0.1

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

    if -43.32005734317631 < (* -2.0 x) < 1.0366643272928921e-05

    1. Initial program 58.9

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

      \[\leadsto \color{blue}{1 \cdot x - \left(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \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 -43.320057343176309 \lor \neg \left(-2 \cdot x \le 1.0366643272928921 \cdot 10^{-5}\right):\\ \;\;\;\;\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right) + \log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\ \end{array}\]

Reproduce

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