Average Error: 29.0 → 0.1
Time: 9.8s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.896697363290915095 \lor \neg \left(-2 \cdot x \le 3.59224269730938628 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{1}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}} \cdot \frac{2}{\sqrt[3]{1 + e^{-2 \cdot x}}} - 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - {x}^{3} \cdot \left(x \cdot 5.55112 \cdot 10^{-17} + 0.33333333333333337\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -0.896697363290915095 \lor \neg \left(-2 \cdot x \le 3.59224269730938628 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{1}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}} \cdot \frac{2}{\sqrt[3]{1 + e^{-2 \cdot x}}} - 1\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r46506 = 2.0;
        double r46507 = 1.0;
        double r46508 = -2.0;
        double r46509 = x;
        double r46510 = r46508 * r46509;
        double r46511 = exp(r46510);
        double r46512 = r46507 + r46511;
        double r46513 = r46506 / r46512;
        double r46514 = r46513 - r46507;
        return r46514;
}

double f(double x, double __attribute__((unused)) y) {
        double r46515 = -2.0;
        double r46516 = x;
        double r46517 = r46515 * r46516;
        double r46518 = -0.8966973632909151;
        bool r46519 = r46517 <= r46518;
        double r46520 = 3.5922426973093863e-06;
        bool r46521 = r46517 <= r46520;
        double r46522 = !r46521;
        bool r46523 = r46519 || r46522;
        double r46524 = 1.0;
        double r46525 = 1.0;
        double r46526 = exp(r46517);
        double r46527 = r46525 + r46526;
        double r46528 = cbrt(r46527);
        double r46529 = r46528 * r46528;
        double r46530 = r46524 / r46529;
        double r46531 = 2.0;
        double r46532 = r46531 / r46528;
        double r46533 = r46530 * r46532;
        double r46534 = r46533 - r46525;
        double r46535 = r46525 * r46516;
        double r46536 = 3.0;
        double r46537 = pow(r46516, r46536);
        double r46538 = 5.551115123125783e-17;
        double r46539 = r46516 * r46538;
        double r46540 = 0.33333333333333337;
        double r46541 = r46539 + r46540;
        double r46542 = r46537 * r46541;
        double r46543 = r46535 - r46542;
        double r46544 = r46523 ? r46534 : r46543;
        return r46544;
}

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.8966973632909151 or 3.5922426973093863e-06 < (* -2.0 x)

    1. Initial program 0.1

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

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

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

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

    if -0.8966973632909151 < (* -2.0 x) < 3.5922426973093863e-06

    1. Initial program 59.1

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Taylor expanded around 0 0.1

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

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

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

Reproduce

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