Average Error: 28.4 → 0.3
Time: 3.7s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -14131.766076203403 \lor \neg \left(-2 \cdot x \le 0.00144583049737171169\right):\\ \;\;\;\;\sqrt[3]{{\left(\frac{2}{1 + e^{-2 \cdot x}} - 1\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, x, -\mathsf{fma}\left(5.55112 \cdot 10^{-17}, {x}^{4}, 0.33333333333333337 \cdot {x}^{3}\right)\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -14131.766076203403 \lor \neg \left(-2 \cdot x \le 0.00144583049737171169\right):\\
\;\;\;\;\sqrt[3]{{\left(\frac{2}{1 + e^{-2 \cdot x}} - 1\right)}^{3}}\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r51551 = 2.0;
        double r51552 = 1.0;
        double r51553 = -2.0;
        double r51554 = x;
        double r51555 = r51553 * r51554;
        double r51556 = exp(r51555);
        double r51557 = r51552 + r51556;
        double r51558 = r51551 / r51557;
        double r51559 = r51558 - r51552;
        return r51559;
}

double f(double x, double __attribute__((unused)) y) {
        double r51560 = -2.0;
        double r51561 = x;
        double r51562 = r51560 * r51561;
        double r51563 = -14131.766076203403;
        bool r51564 = r51562 <= r51563;
        double r51565 = 0.0014458304973717117;
        bool r51566 = r51562 <= r51565;
        double r51567 = !r51566;
        bool r51568 = r51564 || r51567;
        double r51569 = 2.0;
        double r51570 = 1.0;
        double r51571 = exp(r51562);
        double r51572 = r51570 + r51571;
        double r51573 = r51569 / r51572;
        double r51574 = r51573 - r51570;
        double r51575 = 3.0;
        double r51576 = pow(r51574, r51575);
        double r51577 = cbrt(r51576);
        double r51578 = 5.551115123125783e-17;
        double r51579 = 4.0;
        double r51580 = pow(r51561, r51579);
        double r51581 = 0.33333333333333337;
        double r51582 = pow(r51561, r51575);
        double r51583 = r51581 * r51582;
        double r51584 = fma(r51578, r51580, r51583);
        double r51585 = -r51584;
        double r51586 = fma(r51570, r51561, r51585);
        double r51587 = r51568 ? r51577 : r51586;
        return r51587;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Split input into 2 regimes
  2. if (* -2.0 x) < -14131.766076203403 or 0.0014458304973717117 < (* -2.0 x)

    1. Initial program 0.0

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

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

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

    if -14131.766076203403 < (* -2.0 x) < 0.0014458304973717117

    1. Initial program 58.5

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, x, -\mathsf{fma}\left(5.55112 \cdot 10^{-17}, {x}^{4}, 0.33333333333333337 \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 -14131.766076203403 \lor \neg \left(-2 \cdot x \le 0.00144583049737171169\right):\\ \;\;\;\;\sqrt[3]{{\left(\frac{2}{1 + e^{-2 \cdot x}} - 1\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, x, -\mathsf{fma}\left(5.55112 \cdot 10^{-17}, {x}^{4}, 0.33333333333333337 \cdot {x}^{3}\right)\right)\\ \end{array}\]

Reproduce

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