Average Error: 29.2 → 0.0
Time: 15.7s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -8.2837825454566867133809893175566685386 \cdot 10^{-4} \lor \neg \left(x \le 9.8788150810473181542836762503156933235 \cdot 10^{-4}\right):\\ \;\;\;\;\frac{\frac{2}{\sqrt{{\left(e^{-2}\right)}^{x} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}} - 1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(x \cdot x\right) \cdot 0.3333333333333333703407674875052180141211\right) - 5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4}\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;x \le -8.2837825454566867133809893175566685386 \cdot 10^{-4} \lor \neg \left(x \le 9.8788150810473181542836762503156933235 \cdot 10^{-4}\right):\\
\;\;\;\;\frac{\frac{2}{\sqrt{{\left(e^{-2}\right)}^{x} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}} - 1\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r64508 = 2.0;
        double r64509 = 1.0;
        double r64510 = -2.0;
        double r64511 = x;
        double r64512 = r64510 * r64511;
        double r64513 = exp(r64512);
        double r64514 = r64509 + r64513;
        double r64515 = r64508 / r64514;
        double r64516 = r64515 - r64509;
        return r64516;
}

double f(double x, double __attribute__((unused)) y) {
        double r64517 = x;
        double r64518 = -0.0008283782545456687;
        bool r64519 = r64517 <= r64518;
        double r64520 = 0.0009878815081047318;
        bool r64521 = r64517 <= r64520;
        double r64522 = !r64521;
        bool r64523 = r64519 || r64522;
        double r64524 = 2.0;
        double r64525 = -2.0;
        double r64526 = exp(r64525);
        double r64527 = pow(r64526, r64517);
        double r64528 = 1.0;
        double r64529 = r64527 + r64528;
        double r64530 = sqrt(r64529);
        double r64531 = r64524 / r64530;
        double r64532 = exp(r64517);
        double r64533 = pow(r64532, r64525);
        double r64534 = r64533 + r64528;
        double r64535 = sqrt(r64534);
        double r64536 = r64531 / r64535;
        double r64537 = r64536 - r64528;
        double r64538 = r64517 * r64517;
        double r64539 = 0.33333333333333337;
        double r64540 = r64538 * r64539;
        double r64541 = r64528 - r64540;
        double r64542 = r64517 * r64541;
        double r64543 = 5.551115123125783e-17;
        double r64544 = 4.0;
        double r64545 = pow(r64517, r64544);
        double r64546 = r64543 * r64545;
        double r64547 = r64542 - r64546;
        double r64548 = r64523 ? r64537 : r64547;
        return r64548;
}

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 x < -0.0008283782545456687 or 0.0009878815081047318 < x

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Simplified0.0

      \[\leadsto \color{blue}{\frac{2}{1 + {\left(e^{x}\right)}^{-2}} - 1}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt0.0

      \[\leadsto \frac{2}{\color{blue}{\sqrt{1 + {\left(e^{x}\right)}^{-2}} \cdot \sqrt{1 + {\left(e^{x}\right)}^{-2}}}} - 1\]
    5. Applied associate-/r*0.0

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

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

    if -0.0008283782545456687 < x < 0.0009878815081047318

    1. Initial program 59.3

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Simplified59.3

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

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

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

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

Reproduce

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