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

\mathbf{elif}\;-2 \cdot x \le 1.627379555188875196866448791591097666753 \cdot 10^{-8}:\\
\;\;\;\;1 \cdot x - \left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333703407674875052180141211 + \left(x \cdot x\right) \cdot 5.5511151231257827021181583404541015625 \cdot 10^{-17}\right)\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r2129363 = 2.0;
        double r2129364 = 1.0;
        double r2129365 = -2.0;
        double r2129366 = x;
        double r2129367 = r2129365 * r2129366;
        double r2129368 = exp(r2129367);
        double r2129369 = r2129364 + r2129368;
        double r2129370 = r2129363 / r2129369;
        double r2129371 = r2129370 - r2129364;
        return r2129371;
}

double f(double x, double __attribute__((unused)) y) {
        double r2129372 = -2.0;
        double r2129373 = x;
        double r2129374 = r2129372 * r2129373;
        double r2129375 = -0.2905948704643001;
        bool r2129376 = r2129374 <= r2129375;
        double r2129377 = 4.0;
        double r2129378 = exp(r2129374);
        double r2129379 = 1.0;
        double r2129380 = r2129378 + r2129379;
        double r2129381 = r2129380 * r2129380;
        double r2129382 = r2129377 / r2129381;
        double r2129383 = r2129382 - r2129379;
        double r2129384 = exp(r2129383);
        double r2129385 = log(r2129384);
        double r2129386 = 2.0;
        double r2129387 = r2129386 / r2129380;
        double r2129388 = r2129379 + r2129387;
        double r2129389 = r2129385 / r2129388;
        double r2129390 = 1.6273795551888752e-08;
        bool r2129391 = r2129374 <= r2129390;
        double r2129392 = r2129379 * r2129373;
        double r2129393 = r2129373 * r2129373;
        double r2129394 = 0.33333333333333337;
        double r2129395 = r2129373 * r2129394;
        double r2129396 = 5.551115123125783e-17;
        double r2129397 = r2129393 * r2129396;
        double r2129398 = r2129395 + r2129397;
        double r2129399 = r2129393 * r2129398;
        double r2129400 = r2129392 - r2129399;
        double r2129401 = r2129383 / r2129388;
        double r2129402 = r2129391 ? r2129400 : r2129401;
        double r2129403 = r2129376 ? r2129389 : r2129402;
        return r2129403;
}

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

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. 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}}\]
    4. Taylor expanded around inf 0.0

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

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

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

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

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

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

    if -0.2905948704643001 < (* -2.0 x) < 1.6273795551888752e-08

    1. Initial program 59.3

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

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

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

    if 1.6273795551888752e-08 < (* -2.0 x)

    1. Initial program 0.3

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

      \[\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}}\]
    4. Taylor expanded around inf 0.3

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

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

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

Reproduce

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