Average Error: 29.8 → 0.3
Time: 20.1s
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):\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - {x}^{3} \cdot \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x + 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):\\
\;\;\;\;\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}\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r39522 = 2.0;
        double r39523 = 1.0;
        double r39524 = -2.0;
        double r39525 = x;
        double r39526 = r39524 * r39525;
        double r39527 = exp(r39526);
        double r39528 = r39523 + r39527;
        double r39529 = r39522 / r39528;
        double r39530 = r39529 - r39523;
        return r39530;
}

double f(double x, double __attribute__((unused)) y) {
        double r39531 = -2.0;
        double r39532 = x;
        double r39533 = r39531 * r39532;
        double r39534 = -200852.69093066952;
        bool r39535 = r39533 <= r39534;
        double r39536 = 0.0008698543000047537;
        bool r39537 = r39533 <= r39536;
        double r39538 = !r39537;
        bool r39539 = r39535 || r39538;
        double r39540 = 2.0;
        double r39541 = 1.0;
        double r39542 = exp(r39533);
        double r39543 = r39541 + r39542;
        double r39544 = r39540 / r39543;
        double r39545 = r39544 * r39544;
        double r39546 = r39541 * r39541;
        double r39547 = r39545 - r39546;
        double r39548 = r39544 + r39541;
        double r39549 = r39547 / r39548;
        double r39550 = r39541 * r39532;
        double r39551 = 3.0;
        double r39552 = pow(r39532, r39551);
        double r39553 = 5.551115123125783e-17;
        double r39554 = r39553 * r39532;
        double r39555 = 0.33333333333333337;
        double r39556 = r39554 + r39555;
        double r39557 = r39552 * r39556;
        double r39558 = r39550 - r39557;
        double r39559 = r39539 ? r39549 : r39558;
        return r39559;
}

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 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}}\]

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

    1. Initial program 58.5

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. 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)}\]
    3. Simplified0.5

      \[\leadsto \color{blue}{1 \cdot x - {x}^{3} \cdot \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x + 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):\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - {x}^{3} \cdot \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x + 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))