Average Error: 29.6 → 0.0
Time: 12.6s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -9.290475389181829853763039395175837853458 \cdot 10^{-4} \lor \neg \left(x \le 8.133336636844118580288998110461307078367 \cdot 10^{-4}\right):\\ \;\;\;\;\log \left(e^{\frac{2}{1 + {\left(e^{x}\right)}^{-2}} - 1}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 \cdot x - 5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4}\right) - 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;x \le -9.290475389181829853763039395175837853458 \cdot 10^{-4} \lor \neg \left(x \le 8.133336636844118580288998110461307078367 \cdot 10^{-4}\right):\\
\;\;\;\;\log \left(e^{\frac{2}{1 + {\left(e^{x}\right)}^{-2}} - 1}\right)\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r48840 = 2.0;
        double r48841 = 1.0;
        double r48842 = -2.0;
        double r48843 = x;
        double r48844 = r48842 * r48843;
        double r48845 = exp(r48844);
        double r48846 = r48841 + r48845;
        double r48847 = r48840 / r48846;
        double r48848 = r48847 - r48841;
        return r48848;
}

double f(double x, double __attribute__((unused)) y) {
        double r48849 = x;
        double r48850 = -0.000929047538918183;
        bool r48851 = r48849 <= r48850;
        double r48852 = 0.0008133336636844119;
        bool r48853 = r48849 <= r48852;
        double r48854 = !r48853;
        bool r48855 = r48851 || r48854;
        double r48856 = 2.0;
        double r48857 = 1.0;
        double r48858 = exp(r48849);
        double r48859 = -2.0;
        double r48860 = pow(r48858, r48859);
        double r48861 = r48857 + r48860;
        double r48862 = r48856 / r48861;
        double r48863 = r48862 - r48857;
        double r48864 = exp(r48863);
        double r48865 = log(r48864);
        double r48866 = r48857 * r48849;
        double r48867 = 5.551115123125783e-17;
        double r48868 = 4.0;
        double r48869 = pow(r48849, r48868);
        double r48870 = r48867 * r48869;
        double r48871 = r48866 - r48870;
        double r48872 = 0.33333333333333337;
        double r48873 = 3.0;
        double r48874 = pow(r48849, r48873);
        double r48875 = r48872 * r48874;
        double r48876 = r48871 - r48875;
        double r48877 = r48855 ? r48865 : r48876;
        return r48877;
}

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 x < -0.000929047538918183 or 0.0008133336636844119 < x

    1. Initial program 0.1

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Simplified0.1

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

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

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

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

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

    if -0.000929047538918183 < x < 0.0008133336636844119

    1. Initial program 59.1

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Simplified59.1

      \[\leadsto \color{blue}{\frac{2}{1 + {\left(e^{x}\right)}^{-2}} - 1}\]
    3. Using strategy rm
    4. Applied add-log-exp59.1

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

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

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

      \[\leadsto \log \color{blue}{\left(e^{\frac{2}{{\left(e^{x}\right)}^{-2} + 1} - 1}\right)}\]
    8. Taylor expanded around 0 0.0

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

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

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

Reproduce

herbie shell --seed 2019195 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))