Average Error: 28.9 → 0.1
Time: 3.4s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.04639353646233555783506830039186752401292:\\ \;\;\;\;\frac{\left(-1 \cdot 1\right) + \frac{\frac{2 \cdot 2}{\sqrt[3]{{\left(1 + e^{-2 \cdot x}\right)}^{3}}}}{1 + e^{-2 \cdot x}}}{2 \cdot \frac{1}{e^{-2 \cdot x} + 1} + 1}\\ \mathbf{elif}\;-2 \cdot x \le 7.357856183748689123394269679412382258177 \cdot 10^{-11}:\\ \;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(e^{\frac{2}{\frac{{\left(e^{-2 \cdot x} + 1\right)}^{2}}{2}} - 1 \cdot 1}\right)}{2 \cdot \frac{1}{e^{-2 \cdot x} + 1} + 1}\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -0.04639353646233555783506830039186752401292:\\
\;\;\;\;\frac{\left(-1 \cdot 1\right) + \frac{\frac{2 \cdot 2}{\sqrt[3]{{\left(1 + e^{-2 \cdot x}\right)}^{3}}}}{1 + e^{-2 \cdot x}}}{2 \cdot \frac{1}{e^{-2 \cdot x} + 1} + 1}\\

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

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r56843 = 2.0;
        double r56844 = 1.0;
        double r56845 = -2.0;
        double r56846 = x;
        double r56847 = r56845 * r56846;
        double r56848 = exp(r56847);
        double r56849 = r56844 + r56848;
        double r56850 = r56843 / r56849;
        double r56851 = r56850 - r56844;
        return r56851;
}

double f(double x, double __attribute__((unused)) y) {
        double r56852 = -2.0;
        double r56853 = x;
        double r56854 = r56852 * r56853;
        double r56855 = -0.04639353646233556;
        bool r56856 = r56854 <= r56855;
        double r56857 = 1.0;
        double r56858 = r56857 * r56857;
        double r56859 = -r56858;
        double r56860 = 2.0;
        double r56861 = r56860 * r56860;
        double r56862 = exp(r56854);
        double r56863 = r56857 + r56862;
        double r56864 = 3.0;
        double r56865 = pow(r56863, r56864);
        double r56866 = cbrt(r56865);
        double r56867 = r56861 / r56866;
        double r56868 = r56867 / r56863;
        double r56869 = r56859 + r56868;
        double r56870 = 1.0;
        double r56871 = r56862 + r56857;
        double r56872 = r56870 / r56871;
        double r56873 = r56860 * r56872;
        double r56874 = r56873 + r56857;
        double r56875 = r56869 / r56874;
        double r56876 = 7.357856183748689e-11;
        bool r56877 = r56854 <= r56876;
        double r56878 = r56857 * r56853;
        double r56879 = 5.551115123125783e-17;
        double r56880 = 4.0;
        double r56881 = pow(r56853, r56880);
        double r56882 = r56879 * r56881;
        double r56883 = 0.33333333333333337;
        double r56884 = pow(r56853, r56864);
        double r56885 = r56883 * r56884;
        double r56886 = r56882 + r56885;
        double r56887 = r56878 - r56886;
        double r56888 = 2.0;
        double r56889 = pow(r56871, r56888);
        double r56890 = r56889 / r56860;
        double r56891 = r56860 / r56890;
        double r56892 = r56891 - r56858;
        double r56893 = exp(r56892);
        double r56894 = log(r56893);
        double r56895 = r56894 / r56874;
        double r56896 = r56877 ? r56887 : r56895;
        double r56897 = r56856 ? r56875 : r56896;
        return r56897;
}

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.04639353646233556

    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. Using strategy rm
    5. Applied add-cbrt-cube0.0

      \[\leadsto \frac{2}{\sqrt{1 + e^{-2 \cdot x}} \cdot \color{blue}{\sqrt[3]{\left(\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}\right) \cdot \sqrt{1 + e^{-2 \cdot x}}}}} - 1\]
    6. Applied add-cbrt-cube0.0

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

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

      \[\leadsto \frac{2}{\sqrt[3]{\color{blue}{{\left(1 + e^{-2 \cdot x}\right)}^{3}}}} - 1\]
    9. Using strategy rm
    10. Applied flip--0.0

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

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

      \[\leadsto \frac{\left(-1 \cdot 1\right) + \frac{\frac{2 \cdot 2}{1 + e^{-2 \cdot x}}}{1 + e^{-2 \cdot x}}}{\color{blue}{2 \cdot \frac{1}{e^{-2 \cdot x} + 1} + 1}}\]
    13. Using strategy rm
    14. Applied add-cbrt-cube0.0

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

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

    if -0.04639353646233556 < (* -2.0 x) < 7.357856183748689e-11

    1. Initial program 59.5

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

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

    if 7.357856183748689e-11 < (* -2.0 x)

    1. Initial program 0.4

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

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

      \[\leadsto \frac{2}{\sqrt{1 + e^{-2 \cdot x}} \cdot \color{blue}{\sqrt[3]{\left(\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}\right) \cdot \sqrt{1 + e^{-2 \cdot x}}}}} - 1\]
    6. Applied add-cbrt-cube0.5

      \[\leadsto \frac{2}{\color{blue}{\sqrt[3]{\left(\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}\right) \cdot \sqrt{1 + e^{-2 \cdot x}}}} \cdot \sqrt[3]{\left(\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}\right) \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    7. Applied cbrt-unprod0.5

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

      \[\leadsto \frac{2}{\sqrt[3]{\color{blue}{{\left(1 + e^{-2 \cdot x}\right)}^{3}}}} - 1\]
    9. Using strategy rm
    10. Applied flip--0.4

      \[\leadsto \color{blue}{\frac{\frac{2}{\sqrt[3]{{\left(1 + e^{-2 \cdot x}\right)}^{3}}} \cdot \frac{2}{\sqrt[3]{{\left(1 + e^{-2 \cdot x}\right)}^{3}}} - 1 \cdot 1}{\frac{2}{\sqrt[3]{{\left(1 + e^{-2 \cdot x}\right)}^{3}}} + 1}}\]
    11. Simplified0.4

      \[\leadsto \frac{\color{blue}{\left(-1 \cdot 1\right) + \frac{\frac{2 \cdot 2}{1 + e^{-2 \cdot x}}}{1 + e^{-2 \cdot x}}}}{\frac{2}{\sqrt[3]{{\left(1 + e^{-2 \cdot x}\right)}^{3}}} + 1}\]
    12. Simplified0.4

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

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

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

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

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

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

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

Reproduce

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