Average Error: 29.4 → 0.0
Time: 5.5s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.0039848092641429148 \lor \neg \left(-2 \cdot x \le 8.5922675456739933 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{8 \cdot \frac{1}{{\left(e^{-2 \cdot x} + 1\right)}^{3}} - 1}{1 + \left(4 \cdot \frac{1}{{\left({\left(e^{-2 \cdot x} + 1\right)}^{\left(\sqrt[3]{2} \cdot \sqrt[3]{2}\right)}\right)}^{\left(\sqrt[3]{2}\right)}} + 2 \cdot \frac{1}{e^{-2 \cdot x} + 1}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(1 \cdot x + 1.11022 \cdot 10^{-16} \cdot {x}^{4}\right) - 0.333333333333333315 \cdot {x}^{3}\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -0.0039848092641429148 \lor \neg \left(-2 \cdot x \le 8.5922675456739933 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{8 \cdot \frac{1}{{\left(e^{-2 \cdot x} + 1\right)}^{3}} - 1}{1 + \left(4 \cdot \frac{1}{{\left({\left(e^{-2 \cdot x} + 1\right)}^{\left(\sqrt[3]{2} \cdot \sqrt[3]{2}\right)}\right)}^{\left(\sqrt[3]{2}\right)}} + 2 \cdot \frac{1}{e^{-2 \cdot x} + 1}\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(1 \cdot x + 1.11022 \cdot 10^{-16} \cdot {x}^{4}\right) - 0.333333333333333315 \cdot {x}^{3}\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r52449 = 2.0;
        double r52450 = 1.0;
        double r52451 = -2.0;
        double r52452 = x;
        double r52453 = r52451 * r52452;
        double r52454 = exp(r52453);
        double r52455 = r52450 + r52454;
        double r52456 = r52449 / r52455;
        double r52457 = r52456 - r52450;
        return r52457;
}

double f(double x, double __attribute__((unused)) y) {
        double r52458 = -2.0;
        double r52459 = x;
        double r52460 = r52458 * r52459;
        double r52461 = -0.003984809264142915;
        bool r52462 = r52460 <= r52461;
        double r52463 = 8.592267545673993e-05;
        bool r52464 = r52460 <= r52463;
        double r52465 = !r52464;
        bool r52466 = r52462 || r52465;
        double r52467 = 8.0;
        double r52468 = 1.0;
        double r52469 = exp(r52460);
        double r52470 = 1.0;
        double r52471 = r52469 + r52470;
        double r52472 = 3.0;
        double r52473 = pow(r52471, r52472);
        double r52474 = r52468 / r52473;
        double r52475 = r52467 * r52474;
        double r52476 = r52475 - r52470;
        double r52477 = 4.0;
        double r52478 = 2.0;
        double r52479 = cbrt(r52478);
        double r52480 = r52479 * r52479;
        double r52481 = pow(r52471, r52480);
        double r52482 = pow(r52481, r52479);
        double r52483 = r52468 / r52482;
        double r52484 = r52477 * r52483;
        double r52485 = 2.0;
        double r52486 = r52468 / r52471;
        double r52487 = r52485 * r52486;
        double r52488 = r52484 + r52487;
        double r52489 = r52470 + r52488;
        double r52490 = r52476 / r52489;
        double r52491 = r52470 * r52459;
        double r52492 = 1.1102230246251565e-16;
        double r52493 = 4.0;
        double r52494 = pow(r52459, r52493);
        double r52495 = r52492 * r52494;
        double r52496 = r52491 + r52495;
        double r52497 = 0.3333333333333333;
        double r52498 = pow(r52459, r52472);
        double r52499 = r52497 * r52498;
        double r52500 = r52496 - r52499;
        double r52501 = r52466 ? r52490 : r52500;
        return r52501;
}

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.003984809264142915 or 8.592267545673993e-05 < (* -2.0 x)

    1. Initial program 0.1

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

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

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

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

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

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

    if -0.003984809264142915 < (* -2.0 x) < 8.592267545673993e-05

    1. Initial program 59.3

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.0039848092641429148 \lor \neg \left(-2 \cdot x \le 8.5922675456739933 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{8 \cdot \frac{1}{{\left(e^{-2 \cdot x} + 1\right)}^{3}} - 1}{1 + \left(4 \cdot \frac{1}{{\left({\left(e^{-2 \cdot x} + 1\right)}^{\left(\sqrt[3]{2} \cdot \sqrt[3]{2}\right)}\right)}^{\left(\sqrt[3]{2}\right)}} + 2 \cdot \frac{1}{e^{-2 \cdot x} + 1}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(1 \cdot x + 1.11022 \cdot 10^{-16} \cdot {x}^{4}\right) - 0.333333333333333315 \cdot {x}^{3}\\ \end{array}\]

Reproduce

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