Average Error: 28.8 → 0.0
Time: 13.3s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.001044913585978534537046513719360518734902 \lor \neg \left(x \le 8.451041700813264690231307874057620210806 \cdot 10^{-4}\right):\\ \;\;\;\;\log \left(e^{\frac{2}{{\left(e^{-2}\right)}^{x} + 1} - 1}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(x \cdot x\right) \cdot 0.3333333333333333703407674875052180141211\right) - {x}^{4} \cdot 5.5511151231257827021181583404541015625 \cdot 10^{-17}\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;x \le -0.001044913585978534537046513719360518734902 \lor \neg \left(x \le 8.451041700813264690231307874057620210806 \cdot 10^{-4}\right):\\
\;\;\;\;\log \left(e^{\frac{2}{{\left(e^{-2}\right)}^{x} + 1} - 1}\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \left(x \cdot x\right) \cdot 0.3333333333333333703407674875052180141211\right) - {x}^{4} \cdot 5.5511151231257827021181583404541015625 \cdot 10^{-17}\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r42137 = 2.0;
        double r42138 = 1.0;
        double r42139 = -2.0;
        double r42140 = x;
        double r42141 = r42139 * r42140;
        double r42142 = exp(r42141);
        double r42143 = r42138 + r42142;
        double r42144 = r42137 / r42143;
        double r42145 = r42144 - r42138;
        return r42145;
}

double f(double x, double __attribute__((unused)) y) {
        double r42146 = x;
        double r42147 = -0.0010449135859785345;
        bool r42148 = r42146 <= r42147;
        double r42149 = 0.0008451041700813265;
        bool r42150 = r42146 <= r42149;
        double r42151 = !r42150;
        bool r42152 = r42148 || r42151;
        double r42153 = 2.0;
        double r42154 = -2.0;
        double r42155 = exp(r42154);
        double r42156 = pow(r42155, r42146);
        double r42157 = 1.0;
        double r42158 = r42156 + r42157;
        double r42159 = r42153 / r42158;
        double r42160 = r42159 - r42157;
        double r42161 = exp(r42160);
        double r42162 = log(r42161);
        double r42163 = r42146 * r42146;
        double r42164 = 0.33333333333333337;
        double r42165 = r42163 * r42164;
        double r42166 = r42157 - r42165;
        double r42167 = r42146 * r42166;
        double r42168 = 4.0;
        double r42169 = pow(r42146, r42168);
        double r42170 = 5.551115123125783e-17;
        double r42171 = r42169 * r42170;
        double r42172 = r42167 - r42171;
        double r42173 = r42152 ? r42162 : r42172;
        return r42173;
}

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 x < -0.0010449135859785345 or 0.0008451041700813265 < x

    1. Initial program 0.0

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

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

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

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

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

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

    if -0.0010449135859785345 < x < 0.0008451041700813265

    1. Initial program 59.2

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Simplified59.2

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

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

      \[\leadsto \color{blue}{x \cdot \left(1 - \left(x \cdot x\right) \cdot 0.3333333333333333703407674875052180141211\right) - 5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.001044913585978534537046513719360518734902 \lor \neg \left(x \le 8.451041700813264690231307874057620210806 \cdot 10^{-4}\right):\\ \;\;\;\;\log \left(e^{\frac{2}{{\left(e^{-2}\right)}^{x} + 1} - 1}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(x \cdot x\right) \cdot 0.3333333333333333703407674875052180141211\right) - {x}^{4} \cdot 5.5511151231257827021181583404541015625 \cdot 10^{-17}\\ \end{array}\]

Reproduce

herbie shell --seed 2019179 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))