Average Error: 29.7 → 0.0
Time: 31.2s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.004730793410321861:\\ \;\;\;\;\frac{\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1}\right)}{1 + \frac{2}{e^{-2 \cdot x} + 1}}\\ \mathbf{elif}\;x \le 0.00661692382552498:\\ \;\;\;\;\left(x + {x}^{5} \cdot \frac{2}{15}\right) + \left(\left(x \cdot x\right) \cdot x\right) \cdot \frac{-1}{3}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1 + \frac{2}{e^{-2 \cdot x} + 1}}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1}}\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;x \le -0.004730793410321861:\\
\;\;\;\;\frac{\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1}\right)}{1 + \frac{2}{e^{-2 \cdot x} + 1}}\\

\mathbf{elif}\;x \le 0.00661692382552498:\\
\;\;\;\;\left(x + {x}^{5} \cdot \frac{2}{15}\right) + \left(\left(x \cdot x\right) \cdot x\right) \cdot \frac{-1}{3}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1 + \frac{2}{e^{-2 \cdot x} + 1}}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1}}\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r2382075 = 2.0;
        double r2382076 = 1.0;
        double r2382077 = -2.0;
        double r2382078 = x;
        double r2382079 = r2382077 * r2382078;
        double r2382080 = exp(r2382079);
        double r2382081 = r2382076 + r2382080;
        double r2382082 = r2382075 / r2382081;
        double r2382083 = r2382082 - r2382076;
        return r2382083;
}

double f(double x, double __attribute__((unused)) y) {
        double r2382084 = x;
        double r2382085 = -0.004730793410321861;
        bool r2382086 = r2382084 <= r2382085;
        double r2382087 = 2.0;
        double r2382088 = -2.0;
        double r2382089 = r2382088 * r2382084;
        double r2382090 = exp(r2382089);
        double r2382091 = 1.0;
        double r2382092 = r2382090 + r2382091;
        double r2382093 = r2382087 / r2382092;
        double r2382094 = r2382093 * r2382093;
        double r2382095 = r2382094 - r2382091;
        double r2382096 = exp(r2382095);
        double r2382097 = log(r2382096);
        double r2382098 = r2382091 + r2382093;
        double r2382099 = r2382097 / r2382098;
        double r2382100 = 0.00661692382552498;
        bool r2382101 = r2382084 <= r2382100;
        double r2382102 = 5.0;
        double r2382103 = pow(r2382084, r2382102);
        double r2382104 = 0.13333333333333333;
        double r2382105 = r2382103 * r2382104;
        double r2382106 = r2382084 + r2382105;
        double r2382107 = r2382084 * r2382084;
        double r2382108 = r2382107 * r2382084;
        double r2382109 = -0.3333333333333333;
        double r2382110 = r2382108 * r2382109;
        double r2382111 = r2382106 + r2382110;
        double r2382112 = r2382098 / r2382095;
        double r2382113 = r2382091 / r2382112;
        double r2382114 = r2382101 ? r2382111 : r2382113;
        double r2382115 = r2382086 ? r2382099 : r2382114;
        return r2382115;
}

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 x < -0.004730793410321861

    1. Initial program 0.0

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

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

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

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

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

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

    if -0.004730793410321861 < x < 0.00661692382552498

    1. Initial program 59.0

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

      \[\leadsto \color{blue}{2 \cdot \frac{1}{e^{-2 \cdot x} + 1} - 1}\]
    3. Simplified59.0

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

      \[\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}}\]
    6. Simplified59.0

      \[\leadsto \frac{\color{blue}{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1}}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    7. Using strategy rm
    8. Applied add-log-exp59.0

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

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

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

    if 0.00661692382552498 < x

    1. Initial program 0.0

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1}}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    7. Using strategy rm
    8. Applied clear-num0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.004730793410321861:\\ \;\;\;\;\frac{\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1}\right)}{1 + \frac{2}{e^{-2 \cdot x} + 1}}\\ \mathbf{elif}\;x \le 0.00661692382552498:\\ \;\;\;\;\left(x + {x}^{5} \cdot \frac{2}{15}\right) + \left(\left(x \cdot x\right) \cdot x\right) \cdot \frac{-1}{3}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1 + \frac{2}{e^{-2 \cdot x} + 1}}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1}}\\ \end{array}\]

Reproduce

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