Average Error: 29.2 → 0.3
Time: 5.8s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -10.55391129503279401546933513600379228592 \lor \neg \left(-2 \cdot x \le 3.456201489394080829830849858040359851019 \cdot 10^{-10}\right):\\ \;\;\;\;\left(\sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\right) \cdot \sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, x, -\mathsf{fma}\left(5.5511151231257827021181583404541015625 \cdot 10^{-17}, {x}^{4}, 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -10.55391129503279401546933513600379228592 \lor \neg \left(-2 \cdot x \le 3.456201489394080829830849858040359851019 \cdot 10^{-10}\right):\\
\;\;\;\;\left(\sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\right) \cdot \sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1}\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r61588 = 2.0;
        double r61589 = 1.0;
        double r61590 = -2.0;
        double r61591 = x;
        double r61592 = r61590 * r61591;
        double r61593 = exp(r61592);
        double r61594 = r61589 + r61593;
        double r61595 = r61588 / r61594;
        double r61596 = r61595 - r61589;
        return r61596;
}

double f(double x, double __attribute__((unused)) y) {
        double r61597 = -2.0;
        double r61598 = x;
        double r61599 = r61597 * r61598;
        double r61600 = -10.553911295032794;
        bool r61601 = r61599 <= r61600;
        double r61602 = 3.456201489394081e-10;
        bool r61603 = r61599 <= r61602;
        double r61604 = !r61603;
        bool r61605 = r61601 || r61604;
        double r61606 = 2.0;
        double r61607 = 1.0;
        double r61608 = exp(r61599);
        double r61609 = r61607 + r61608;
        double r61610 = r61606 / r61609;
        double r61611 = r61610 - r61607;
        double r61612 = cbrt(r61611);
        double r61613 = exp(r61611);
        double r61614 = log(r61613);
        double r61615 = cbrt(r61614);
        double r61616 = r61612 * r61615;
        double r61617 = r61616 * r61612;
        double r61618 = 5.551115123125783e-17;
        double r61619 = 4.0;
        double r61620 = pow(r61598, r61619);
        double r61621 = 0.33333333333333337;
        double r61622 = 3.0;
        double r61623 = pow(r61598, r61622);
        double r61624 = r61621 * r61623;
        double r61625 = fma(r61618, r61620, r61624);
        double r61626 = -r61625;
        double r61627 = fma(r61607, r61598, r61626);
        double r61628 = r61605 ? r61617 : r61627;
        return r61628;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Split input into 2 regimes
  2. if (* -2.0 x) < -10.553911295032794 or 3.456201489394081e-10 < (* -2.0 x)

    1. Initial program 0.2

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1} \cdot \sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right) \cdot \sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\]
    4. Using strategy rm
    5. Applied add-log-exp0.2

      \[\leadsto \left(\sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1} \cdot \sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - \color{blue}{\log \left(e^{1}\right)}}\right) \cdot \sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1}\]
    6. Applied add-log-exp0.2

      \[\leadsto \left(\sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1} \cdot \sqrt[3]{\color{blue}{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}}}\right)} - \log \left(e^{1}\right)}\right) \cdot \sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1}\]
    7. Applied diff-log0.2

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

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

    if -10.553911295032794 < (* -2.0 x) < 3.456201489394081e-10

    1. Initial program 59.0

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

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

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

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

Reproduce

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