Average Error: 29.6 → 0.0
Time: 25.6s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.697568994619957456412850937965686171083 \cdot 10^{-4}:\\ \;\;\;\;\frac{\sqrt[3]{{\left(\frac{\frac{2}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}\right)}^{3} - {1}^{3}} \cdot \left(\sqrt[3]{{\left(\frac{\frac{2}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}\right)}^{3} - {1}^{3}} \cdot \sqrt[3]{{\left(\frac{\frac{2}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}\right)}^{3} - {1}^{3}}\right)}{\frac{\frac{2}{\sqrt{1 + {\left(e^{-2}\right)}^{x}}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}} \cdot \frac{\frac{2}{\sqrt{1 + {\left(e^{-2}\right)}^{x}}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}} + \left(\frac{\frac{2}{\sqrt{1 + {\left(e^{-2}\right)}^{x}}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}} + 1\right) \cdot 1}\\ \mathbf{elif}\;x \le 9.373392480654200173764700743106459412957 \cdot 10^{-4}:\\ \;\;\;\;1 \cdot x - \left(0.3333333333333333703407674875052180141211 \cdot {x}^{3} + 5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{\left(e^{x}\right)}^{-2} + 1} - 1\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;x \le -6.697568994619957456412850937965686171083 \cdot 10^{-4}:\\
\;\;\;\;\frac{\sqrt[3]{{\left(\frac{\frac{2}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}\right)}^{3} - {1}^{3}} \cdot \left(\sqrt[3]{{\left(\frac{\frac{2}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}\right)}^{3} - {1}^{3}} \cdot \sqrt[3]{{\left(\frac{\frac{2}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}\right)}^{3} - {1}^{3}}\right)}{\frac{\frac{2}{\sqrt{1 + {\left(e^{-2}\right)}^{x}}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}} \cdot \frac{\frac{2}{\sqrt{1 + {\left(e^{-2}\right)}^{x}}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}} + \left(\frac{\frac{2}{\sqrt{1 + {\left(e^{-2}\right)}^{x}}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}} + 1\right) \cdot 1}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{2}{{\left(e^{x}\right)}^{-2} + 1} - 1\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r69453 = 2.0;
        double r69454 = 1.0;
        double r69455 = -2.0;
        double r69456 = x;
        double r69457 = r69455 * r69456;
        double r69458 = exp(r69457);
        double r69459 = r69454 + r69458;
        double r69460 = r69453 / r69459;
        double r69461 = r69460 - r69454;
        return r69461;
}

double f(double x, double __attribute__((unused)) y) {
        double r69462 = x;
        double r69463 = -0.0006697568994619957;
        bool r69464 = r69462 <= r69463;
        double r69465 = 2.0;
        double r69466 = exp(r69462);
        double r69467 = -2.0;
        double r69468 = pow(r69466, r69467);
        double r69469 = 1.0;
        double r69470 = r69468 + r69469;
        double r69471 = sqrt(r69470);
        double r69472 = r69465 / r69471;
        double r69473 = r69472 / r69471;
        double r69474 = 3.0;
        double r69475 = pow(r69473, r69474);
        double r69476 = pow(r69469, r69474);
        double r69477 = r69475 - r69476;
        double r69478 = cbrt(r69477);
        double r69479 = r69478 * r69478;
        double r69480 = r69478 * r69479;
        double r69481 = exp(r69467);
        double r69482 = pow(r69481, r69462);
        double r69483 = r69469 + r69482;
        double r69484 = sqrt(r69483);
        double r69485 = r69465 / r69484;
        double r69486 = r69485 / r69471;
        double r69487 = r69486 * r69486;
        double r69488 = r69486 + r69469;
        double r69489 = r69488 * r69469;
        double r69490 = r69487 + r69489;
        double r69491 = r69480 / r69490;
        double r69492 = 0.00093733924806542;
        bool r69493 = r69462 <= r69492;
        double r69494 = r69469 * r69462;
        double r69495 = 0.33333333333333337;
        double r69496 = pow(r69462, r69474);
        double r69497 = r69495 * r69496;
        double r69498 = 5.551115123125783e-17;
        double r69499 = 4.0;
        double r69500 = pow(r69462, r69499);
        double r69501 = r69498 * r69500;
        double r69502 = r69497 + r69501;
        double r69503 = r69494 - r69502;
        double r69504 = r69465 / r69470;
        double r69505 = r69504 - r69469;
        double r69506 = r69493 ? r69503 : r69505;
        double r69507 = r69464 ? r69491 : r69506;
        return r69507;
}

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 3 regimes
  2. if x < -0.0006697568994619957

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{2}{\sqrt{{\left(e^{-2}\right)}^{x} + 1}}}}{\sqrt{1 + {\left(e^{x}\right)}^{-2}}} - 1\]
    7. Using strategy rm
    8. Applied flip3--0.1

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

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

      \[\leadsto \frac{{\left(\frac{\frac{2}{\sqrt{{\left(e^{-2}\right)}^{x} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}\right)}^{3} - {1}^{3}}{\color{blue}{\left(\frac{\frac{2}{\sqrt{{\left(e^{-2}\right)}^{x} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}} + 1\right) \cdot 1 + \frac{\frac{2}{\sqrt{{\left(e^{-2}\right)}^{x} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}} \cdot \frac{\frac{2}{\sqrt{{\left(e^{-2}\right)}^{x} + 1}}}{\sqrt{{\left(e^{x}\right)}^{-2} + 1}}}}\]
    11. Using strategy rm
    12. Applied add-cube-cbrt0.1

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

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

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

    if -0.0006697568994619957 < x < 0.00093733924806542

    1. Initial program 59.2

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

      \[\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 1 - \left(0.3333333333333333703407674875052180141211 \cdot {x}^{3} + 5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4}\right)}\]

    if 0.00093733924806542 < 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. Recombined 3 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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