Average Error: 29.6 → 0.1
Time: 12.4s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.6402867958490563449203136769938282668591 \lor \neg \left(-2 \cdot x \le 6.305606613254815869949905515756682916617 \cdot 10^{-7}\right):\\ \;\;\;\;\sqrt[3]{{\left(\frac{2}{1 + e^{-2 \cdot x}} - 1\right)}^{3}}\\ \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 -0.6402867958490563449203136769938282668591 \lor \neg \left(-2 \cdot x \le 6.305606613254815869949905515756682916617 \cdot 10^{-7}\right):\\
\;\;\;\;\sqrt[3]{{\left(\frac{2}{1 + e^{-2 \cdot x}} - 1\right)}^{3}}\\

\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 r46404 = 2.0;
        double r46405 = 1.0;
        double r46406 = -2.0;
        double r46407 = x;
        double r46408 = r46406 * r46407;
        double r46409 = exp(r46408);
        double r46410 = r46405 + r46409;
        double r46411 = r46404 / r46410;
        double r46412 = r46411 - r46405;
        return r46412;
}

double f(double x, double __attribute__((unused)) y) {
        double r46413 = -2.0;
        double r46414 = x;
        double r46415 = r46413 * r46414;
        double r46416 = -0.6402867958490563;
        bool r46417 = r46415 <= r46416;
        double r46418 = 6.305606613254816e-07;
        bool r46419 = r46415 <= r46418;
        double r46420 = !r46419;
        bool r46421 = r46417 || r46420;
        double r46422 = 2.0;
        double r46423 = 1.0;
        double r46424 = exp(r46415);
        double r46425 = r46423 + r46424;
        double r46426 = r46422 / r46425;
        double r46427 = r46426 - r46423;
        double r46428 = 3.0;
        double r46429 = pow(r46427, r46428);
        double r46430 = cbrt(r46429);
        double r46431 = r46423 * r46414;
        double r46432 = 5.551115123125783e-17;
        double r46433 = 4.0;
        double r46434 = pow(r46414, r46433);
        double r46435 = r46432 * r46434;
        double r46436 = 0.33333333333333337;
        double r46437 = pow(r46414, r46428);
        double r46438 = r46436 * r46437;
        double r46439 = r46435 + r46438;
        double r46440 = r46431 - r46439;
        double r46441 = r46421 ? r46430 : r46440;
        return r46441;
}

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) < -0.6402867958490563 or 6.305606613254816e-07 < (* -2.0 x)

    1. Initial program 0.1

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

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

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

    if -0.6402867958490563 < (* -2.0 x) < 6.305606613254816e-07

    1. Initial program 59.3

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

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

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

      \[\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.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.6402867958490563449203136769938282668591 \lor \neg \left(-2 \cdot x \le 6.305606613254815869949905515756682916617 \cdot 10^{-7}\right):\\ \;\;\;\;\sqrt[3]{{\left(\frac{2}{1 + e^{-2 \cdot x}} - 1\right)}^{3}}\\ \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 2019351 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  :precision binary64
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))