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

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r33471 = 2.0;
        double r33472 = 1.0;
        double r33473 = -2.0;
        double r33474 = x;
        double r33475 = r33473 * r33474;
        double r33476 = exp(r33475);
        double r33477 = r33472 + r33476;
        double r33478 = r33471 / r33477;
        double r33479 = r33478 - r33472;
        return r33479;
}

double f(double x, double __attribute__((unused)) y) {
        double r33480 = -2.0;
        double r33481 = x;
        double r33482 = r33480 * r33481;
        double r33483 = -57837.87936140413;
        bool r33484 = r33482 <= r33483;
        double r33485 = 5.996013450899828e-06;
        bool r33486 = r33482 <= r33485;
        double r33487 = !r33486;
        bool r33488 = r33484 || r33487;
        double r33489 = 2.0;
        double r33490 = 1.0;
        double r33491 = exp(r33482);
        double r33492 = r33490 + r33491;
        double r33493 = sqrt(r33492);
        double r33494 = r33489 / r33493;
        double r33495 = r33494 / r33493;
        double r33496 = r33495 - r33490;
        double r33497 = r33490 * r33481;
        double r33498 = 5.551115123125783e-17;
        double r33499 = 4.0;
        double r33500 = pow(r33481, r33499);
        double r33501 = r33498 * r33500;
        double r33502 = 0.33333333333333337;
        double r33503 = 3.0;
        double r33504 = pow(r33481, r33503);
        double r33505 = r33502 * r33504;
        double r33506 = r33501 + r33505;
        double r33507 = r33497 - r33506;
        double r33508 = r33488 ? r33496 : r33507;
        return r33508;
}

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) < -57837.87936140413 or 5.996013450899828e-06 < (* -2.0 x)

    1. Initial program 0.0

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

      \[\leadsto \frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied associate-/r*0.1

      \[\leadsto \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1\]

    if -57837.87936140413 < (* -2.0 x) < 5.996013450899828e-06

    1. Initial program 58.7

      \[\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. Recombined 2 regimes into one program.
  4. Final simplification0.3

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

Reproduce

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