Average Error: 29.8 → 0.3
Time: 21.4s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -200852.6909306695160921663045883178710938 \lor \neg \left(-2 \cdot x \le 8.698543000047536614266485699431541434024 \cdot 10^{-4}\right):\\ \;\;\;\;\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}}}\right) - 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - {x}^{3} \cdot \left(x \cdot 5.5511151231257827021181583404541015625 \cdot 10^{-17} + 0.3333333333333333703407674875052180141211\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -200852.6909306695160921663045883178710938 \lor \neg \left(-2 \cdot x \le 8.698543000047536614266485699431541434024 \cdot 10^{-4}\right):\\
\;\;\;\;\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}}}\right) - 1\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r37355 = 2.0;
        double r37356 = 1.0;
        double r37357 = -2.0;
        double r37358 = x;
        double r37359 = r37357 * r37358;
        double r37360 = exp(r37359);
        double r37361 = r37356 + r37360;
        double r37362 = r37355 / r37361;
        double r37363 = r37362 - r37356;
        return r37363;
}

double f(double x, double __attribute__((unused)) y) {
        double r37364 = -2.0;
        double r37365 = x;
        double r37366 = r37364 * r37365;
        double r37367 = -200852.69093066952;
        bool r37368 = r37366 <= r37367;
        double r37369 = 0.0008698543000047537;
        bool r37370 = r37366 <= r37369;
        double r37371 = !r37370;
        bool r37372 = r37368 || r37371;
        double r37373 = 2.0;
        double r37374 = 1.0;
        double r37375 = exp(r37366);
        double r37376 = r37374 + r37375;
        double r37377 = r37373 / r37376;
        double r37378 = exp(r37377);
        double r37379 = log(r37378);
        double r37380 = r37379 - r37374;
        double r37381 = r37374 * r37365;
        double r37382 = 3.0;
        double r37383 = pow(r37365, r37382);
        double r37384 = 5.551115123125783e-17;
        double r37385 = r37365 * r37384;
        double r37386 = 0.33333333333333337;
        double r37387 = r37385 + r37386;
        double r37388 = r37383 * r37387;
        double r37389 = r37381 - r37388;
        double r37390 = r37372 ? r37380 : r37389;
        return r37390;
}

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 (* -2.0 x) < -200852.69093066952 or 0.0008698543000047537 < (* -2.0 x)

    1. Initial program 0.0

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

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

    if -200852.69093066952 < (* -2.0 x) < 0.0008698543000047537

    1. Initial program 58.5

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

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

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

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

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

Reproduce

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