Average Error: 29.4 → 0.6
Time: 8.3s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le \frac{-6894184257841097}{268435456} \lor \neg \left(-2 \cdot x \le \frac{6825654194944583}{1208925819614629174706176}\right):\\ \;\;\;\;\frac{\log \left(e^{\frac{2}{\frac{{\left(e^{-2 \cdot x} + 1\right)}^{2}}{2}} - 1 \cdot 1}\right)}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(\frac{1}{18014398509481984} \cdot {x}^{4} + \frac{3002399751580331}{9007199254740992} \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le \frac{-6894184257841097}{268435456} \lor \neg \left(-2 \cdot x \le \frac{6825654194944583}{1208925819614629174706176}\right):\\
\;\;\;\;\frac{\log \left(e^{\frac{2}{\frac{{\left(e^{-2 \cdot x} + 1\right)}^{2}}{2}} - 1 \cdot 1}\right)}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot x - \left(\frac{1}{18014398509481984} \cdot {x}^{4} + \frac{3002399751580331}{9007199254740992} \cdot {x}^{3}\right)\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r49725 = 2.0;
        double r49726 = 1.0;
        double r49727 = -2.0;
        double r49728 = x;
        double r49729 = r49727 * r49728;
        double r49730 = exp(r49729);
        double r49731 = r49726 + r49730;
        double r49732 = r49725 / r49731;
        double r49733 = r49732 - r49726;
        return r49733;
}

double f(double x, double __attribute__((unused)) y) {
        double r49734 = -2.0;
        double r49735 = x;
        double r49736 = r49734 * r49735;
        double r49737 = -6894184257841097.0;
        double r49738 = 268435456.0;
        double r49739 = r49737 / r49738;
        bool r49740 = r49736 <= r49739;
        double r49741 = 6825654194944583.0;
        double r49742 = 1.2089258196146292e+24;
        double r49743 = r49741 / r49742;
        bool r49744 = r49736 <= r49743;
        double r49745 = !r49744;
        bool r49746 = r49740 || r49745;
        double r49747 = 2.0;
        double r49748 = exp(r49736);
        double r49749 = 1.0;
        double r49750 = r49748 + r49749;
        double r49751 = 2.0;
        double r49752 = pow(r49750, r49751);
        double r49753 = r49752 / r49747;
        double r49754 = r49747 / r49753;
        double r49755 = r49749 * r49749;
        double r49756 = r49754 - r49755;
        double r49757 = exp(r49756);
        double r49758 = log(r49757);
        double r49759 = r49749 + r49748;
        double r49760 = r49747 / r49759;
        double r49761 = r49760 + r49749;
        double r49762 = r49758 / r49761;
        double r49763 = r49749 * r49735;
        double r49764 = 18014398509481984.0;
        double r49765 = r49749 / r49764;
        double r49766 = 4.0;
        double r49767 = pow(r49735, r49766);
        double r49768 = r49765 * r49767;
        double r49769 = 3002399751580331.0;
        double r49770 = 9007199254740992.0;
        double r49771 = r49769 / r49770;
        double r49772 = 3.0;
        double r49773 = pow(r49735, r49772);
        double r49774 = r49771 * r49773;
        double r49775 = r49768 + r49774;
        double r49776 = r49763 - r49775;
        double r49777 = r49746 ? r49762 : r49776;
        return r49777;
}

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) < -25682837.73154429 or 5.646048818049403e-09 < (* -2.0 x)

    1. Initial program 0.2

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

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

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

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

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

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

    if -25682837.73154429 < (* -2.0 x) < 5.646048818049403e-09

    1. Initial program 58.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le \frac{-6894184257841097}{268435456} \lor \neg \left(-2 \cdot x \le \frac{6825654194944583}{1208925819614629174706176}\right):\\ \;\;\;\;\frac{\log \left(e^{\frac{2}{\frac{{\left(e^{-2 \cdot x} + 1\right)}^{2}}{2}} - 1 \cdot 1}\right)}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(\frac{1}{18014398509481984} \cdot {x}^{4} + \frac{3002399751580331}{9007199254740992} \cdot {x}^{3}\right)\\ \end{array}\]

Reproduce

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