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

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r60907 = 2.0;
        double r60908 = 1.0;
        double r60909 = -2.0;
        double r60910 = x;
        double r60911 = r60909 * r60910;
        double r60912 = exp(r60911);
        double r60913 = r60908 + r60912;
        double r60914 = r60907 / r60913;
        double r60915 = r60914 - r60908;
        return r60915;
}

double f(double x, double __attribute__((unused)) y) {
        double r60916 = -2.0;
        double r60917 = x;
        double r60918 = r60916 * r60917;
        double r60919 = -0.006660654438723101;
        bool r60920 = r60918 <= r60919;
        double r60921 = 2.0;
        double r60922 = 1.0;
        double r60923 = exp(r60918);
        double r60924 = r60922 + r60923;
        double r60925 = r60921 / r60924;
        double r60926 = r60925 - r60922;
        double r60927 = exp(r60926);
        double r60928 = sqrt(r60927);
        double r60929 = log(r60928);
        double r60930 = cbrt(r60929);
        double r60931 = r60930 * r60930;
        double r60932 = r60931 * r60930;
        double r60933 = r60932 + r60929;
        double r60934 = 5.083912517384329e-05;
        bool r60935 = r60918 <= r60934;
        double r60936 = r60922 * r60917;
        double r60937 = 3.0;
        double r60938 = pow(r60917, r60937);
        double r60939 = 5.551115123125783e-17;
        double r60940 = r60939 * r60917;
        double r60941 = 0.33333333333333337;
        double r60942 = r60940 + r60941;
        double r60943 = r60938 * r60942;
        double r60944 = r60936 - r60943;
        double r60945 = sqrt(r60921);
        double r60946 = sqrt(r60924);
        double r60947 = r60945 / r60946;
        double r60948 = sqrt(r60922);
        double r60949 = r60947 + r60948;
        double r60950 = r60947 - r60948;
        double r60951 = r60949 * r60950;
        double r60952 = exp(r60951);
        double r60953 = sqrt(r60952);
        double r60954 = log(r60953);
        double r60955 = r60929 + r60954;
        double r60956 = r60935 ? r60944 : r60955;
        double r60957 = r60920 ? r60933 : r60956;
        return r60957;
}

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

    1. Initial program 0.0

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

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

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

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

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

      \[\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.0

      \[\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)}\]
    10. Using strategy rm
    11. Applied add-cube-cbrt0.0

      \[\leadsto \color{blue}{\left(\sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)} \cdot \sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)}\right) \cdot \sqrt[3]{\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 -0.006660654438723101 < (* -2.0 x) < 5.083912517384329e-05

    1. Initial program 59.2

      \[\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)}\]
    3. Simplified0.0

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

    if 5.083912517384329e-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)}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt0.1

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.006660654438723100610741933991221230826341:\\ \;\;\;\;\left(\sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)} \cdot \sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)}\right) \cdot \sqrt[3]{\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{elif}\;-2 \cdot x \le 5.083912517384328794752684776980800052115 \cdot 10^{-5}:\\ \;\;\;\;1 \cdot x - {x}^{3} \cdot \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x + 0.3333333333333333703407674875052180141211\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right) + \log \left(\sqrt{e^{\left(\frac{\sqrt{2}}{\sqrt{1 + e^{-2 \cdot x}}} + \sqrt{1}\right) \cdot \left(\frac{\sqrt{2}}{\sqrt{1 + e^{-2 \cdot x}}} - \sqrt{1}\right)}}\right)\\ \end{array}\]

Reproduce

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