Average Error: 29.0 → 0.1
Time: 9.7s
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 r46526 = 2.0;
        double r46527 = 1.0;
        double r46528 = -2.0;
        double r46529 = x;
        double r46530 = r46528 * r46529;
        double r46531 = exp(r46530);
        double r46532 = r46527 + r46531;
        double r46533 = r46526 / r46532;
        double r46534 = r46533 - r46527;
        return r46534;
}

double f(double x, double __attribute__((unused)) y) {
        double r46535 = -2.0;
        double r46536 = x;
        double r46537 = r46535 * r46536;
        double r46538 = -0.8966973632909151;
        bool r46539 = r46537 <= r46538;
        double r46540 = 3.5922426973093863e-06;
        bool r46541 = r46537 <= r46540;
        double r46542 = !r46541;
        bool r46543 = r46539 || r46542;
        double r46544 = 1.0;
        double r46545 = 1.0;
        double r46546 = exp(r46537);
        double r46547 = r46545 + r46546;
        double r46548 = cbrt(r46547);
        double r46549 = r46548 * r46548;
        double r46550 = r46544 / r46549;
        double r46551 = 2.0;
        double r46552 = r46551 / r46548;
        double r46553 = r46550 * r46552;
        double r46554 = r46553 - r46545;
        double r46555 = r46545 * r46536;
        double r46556 = 3.0;
        double r46557 = pow(r46536, r46556);
        double r46558 = 5.551115123125783e-17;
        double r46559 = r46536 * r46558;
        double r46560 = 0.33333333333333337;
        double r46561 = r46559 + r46560;
        double r46562 = r46557 * r46561;
        double r46563 = r46555 - r46562;
        double r46564 = r46543 ? r46554 : r46563;
        return r46564;
}

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))