Average Error: 28.7 → 0.3
Time: 2.9s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -977.014450215970214 \lor \neg \left(-2 \cdot x \le 1.2659887366565751 \cdot 10^{-5}\right):\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -977.014450215970214 \lor \neg \left(-2 \cdot x \le 1.2659887366565751 \cdot 10^{-5}\right):\\
\;\;\;\;\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}\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r43416 = 2.0;
        double r43417 = 1.0;
        double r43418 = -2.0;
        double r43419 = x;
        double r43420 = r43418 * r43419;
        double r43421 = exp(r43420);
        double r43422 = r43417 + r43421;
        double r43423 = r43416 / r43422;
        double r43424 = r43423 - r43417;
        return r43424;
}

double f(double x, double __attribute__((unused)) y) {
        double r43425 = -2.0;
        double r43426 = x;
        double r43427 = r43425 * r43426;
        double r43428 = -977.0144502159702;
        bool r43429 = r43427 <= r43428;
        double r43430 = 1.2659887366565751e-05;
        bool r43431 = r43427 <= r43430;
        double r43432 = !r43431;
        bool r43433 = r43429 || r43432;
        double r43434 = 2.0;
        double r43435 = 1.0;
        double r43436 = exp(r43427);
        double r43437 = r43435 + r43436;
        double r43438 = r43434 / r43437;
        double r43439 = r43438 - r43435;
        double r43440 = cbrt(r43439);
        double r43441 = r43440 * r43440;
        double r43442 = r43441 * r43440;
        double r43443 = r43435 * r43426;
        double r43444 = 5.551115123125783e-17;
        double r43445 = 4.0;
        double r43446 = pow(r43426, r43445);
        double r43447 = r43444 * r43446;
        double r43448 = 0.33333333333333337;
        double r43449 = 3.0;
        double r43450 = pow(r43426, r43449);
        double r43451 = r43448 * r43450;
        double r43452 = r43447 + r43451;
        double r43453 = r43443 - r43452;
        double r43454 = r43433 ? r43442 : r43453;
        return r43454;
}

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) < -977.0144502159702 or 1.2659887366565751e-05 < (* -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 \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}}\]

    if -977.0144502159702 < (* -2.0 x) < 1.2659887366565751e-05

    1. Initial program 58.7

      \[\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. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -977.014450215970214 \lor \neg \left(-2 \cdot x \le 1.2659887366565751 \cdot 10^{-5}\right):\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\ \end{array}\]

Reproduce

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