Average Error: 29.1 → 0.1
Time: 12.7s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.03157346372008180968027346580129233188927:\\ \;\;\;\;\frac{\frac{{\left({\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3}\right)}^{3} - {\left({1}^{3}\right)}^{3}}{\left({\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{6} + {1}^{6}\right) + {\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} \cdot {1}^{3}}}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}\\ \mathbf{elif}\;-2 \cdot x \le 6.844737773194051430364522048410691468234 \cdot 10^{-7}:\\ \;\;\;\;\left(1 \cdot x + 1.1102230246251565404236316680908203125 \cdot 10^{-16} \cdot {x}^{4}\right) - 0.3333333333333333148296162562473909929395 \cdot {x}^{3}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{\frac{3}{2}} + {\left(\sqrt{1}\right)}^{3}}{\frac{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{\frac{3}{2}} - {\left(\sqrt{1}\right)}^{3}}}\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -0.03157346372008180968027346580129233188927:\\
\;\;\;\;\frac{\frac{{\left({\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3}\right)}^{3} - {\left({1}^{3}\right)}^{3}}{\left({\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{6} + {1}^{6}\right) + {\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} \cdot {1}^{3}}}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}\\

\mathbf{elif}\;-2 \cdot x \le 6.844737773194051430364522048410691468234 \cdot 10^{-7}:\\
\;\;\;\;\left(1 \cdot x + 1.1102230246251565404236316680908203125 \cdot 10^{-16} \cdot {x}^{4}\right) - 0.3333333333333333148296162562473909929395 \cdot {x}^{3}\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r60975 = 2.0;
        double r60976 = 1.0;
        double r60977 = -2.0;
        double r60978 = x;
        double r60979 = r60977 * r60978;
        double r60980 = exp(r60979);
        double r60981 = r60976 + r60980;
        double r60982 = r60975 / r60981;
        double r60983 = r60982 - r60976;
        return r60983;
}

double f(double x, double __attribute__((unused)) y) {
        double r60984 = -2.0;
        double r60985 = x;
        double r60986 = r60984 * r60985;
        double r60987 = -0.03157346372008181;
        bool r60988 = r60986 <= r60987;
        double r60989 = 2.0;
        double r60990 = 1.0;
        double r60991 = exp(r60986);
        double r60992 = r60990 + r60991;
        double r60993 = r60989 / r60992;
        double r60994 = 3.0;
        double r60995 = pow(r60993, r60994);
        double r60996 = pow(r60995, r60994);
        double r60997 = pow(r60990, r60994);
        double r60998 = pow(r60997, r60994);
        double r60999 = r60996 - r60998;
        double r61000 = 6.0;
        double r61001 = pow(r60993, r61000);
        double r61002 = pow(r60990, r61000);
        double r61003 = r61001 + r61002;
        double r61004 = r60995 * r60997;
        double r61005 = r61003 + r61004;
        double r61006 = r60999 / r61005;
        double r61007 = r60991 + r60990;
        double r61008 = r60989 / r61007;
        double r61009 = r60990 + r61008;
        double r61010 = r61008 * r61009;
        double r61011 = r60990 * r60990;
        double r61012 = r61010 + r61011;
        double r61013 = r61006 / r61012;
        double r61014 = 6.844737773194051e-07;
        bool r61015 = r60986 <= r61014;
        double r61016 = r60990 * r60985;
        double r61017 = 1.1102230246251565e-16;
        double r61018 = 4.0;
        double r61019 = pow(r60985, r61018);
        double r61020 = r61017 * r61019;
        double r61021 = r61016 + r61020;
        double r61022 = 0.3333333333333333;
        double r61023 = pow(r60985, r60994);
        double r61024 = r61022 * r61023;
        double r61025 = r61021 - r61024;
        double r61026 = 1.5;
        double r61027 = pow(r60993, r61026);
        double r61028 = sqrt(r60990);
        double r61029 = pow(r61028, r60994);
        double r61030 = r61027 + r61029;
        double r61031 = r61027 - r61029;
        double r61032 = r61012 / r61031;
        double r61033 = r61030 / r61032;
        double r61034 = r61015 ? r61025 : r61033;
        double r61035 = r60988 ? r61013 : r61034;
        return r61035;
}

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

    1. Initial program 0.0

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

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

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

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

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

    if -0.03157346372008181 < (* -2.0 x) < 6.844737773194051e-07

    1. Initial program 59.2

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

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

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

      \[\leadsto \color{blue}{\left(1 \cdot x + 1.1102230246251565404236316680908203125 \cdot 10^{-16} \cdot {x}^{4}\right) - 0.3333333333333333148296162562473909929395 \cdot {x}^{3}}\]

    if 6.844737773194051e-07 < (* -2.0 x)

    1. Initial program 0.2

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left({\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{\left(\frac{3}{2}\right)} + {\left(\sqrt{1}\right)}^{3}\right) \cdot \left({\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{\left(\frac{3}{2}\right)} - {\left(\sqrt{1}\right)}^{3}\right)}}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}\]
    10. Applied associate-/l*0.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.03157346372008180968027346580129233188927:\\ \;\;\;\;\frac{\frac{{\left({\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3}\right)}^{3} - {\left({1}^{3}\right)}^{3}}{\left({\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{6} + {1}^{6}\right) + {\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} \cdot {1}^{3}}}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}\\ \mathbf{elif}\;-2 \cdot x \le 6.844737773194051430364522048410691468234 \cdot 10^{-7}:\\ \;\;\;\;\left(1 \cdot x + 1.1102230246251565404236316680908203125 \cdot 10^{-16} \cdot {x}^{4}\right) - 0.3333333333333333148296162562473909929395 \cdot {x}^{3}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{\frac{3}{2}} + {\left(\sqrt{1}\right)}^{3}}{\frac{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{\frac{3}{2}} - {\left(\sqrt{1}\right)}^{3}}}\\ \end{array}\]

Reproduce

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