Average Error: 29.6 → 1.3
Time: 31.7s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -864984669564619502649344 \lor \neg \left(-2 \cdot x \le 4.629032879111215459799953089899127167683 \cdot 10^{-8}\right):\\ \;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt[3]{{\left(\sqrt{e^{-2 \cdot x} + 1}\right)}^{3}}} - 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -864984669564619502649344 \lor \neg \left(-2 \cdot x \le 4.629032879111215459799953089899127167683 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt[3]{{\left(\sqrt{e^{-2 \cdot x} + 1}\right)}^{3}}} - 1\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r36998 = 2.0;
        double r36999 = 1.0;
        double r37000 = -2.0;
        double r37001 = x;
        double r37002 = r37000 * r37001;
        double r37003 = exp(r37002);
        double r37004 = r36999 + r37003;
        double r37005 = r36998 / r37004;
        double r37006 = r37005 - r36999;
        return r37006;
}

double f(double x, double __attribute__((unused)) y) {
        double r37007 = -2.0;
        double r37008 = x;
        double r37009 = r37007 * r37008;
        double r37010 = -8.649846695646195e+23;
        bool r37011 = r37009 <= r37010;
        double r37012 = 4.6290328791112155e-08;
        bool r37013 = r37009 <= r37012;
        double r37014 = !r37013;
        bool r37015 = r37011 || r37014;
        double r37016 = 2.0;
        double r37017 = 1.0;
        double r37018 = exp(r37009);
        double r37019 = r37017 + r37018;
        double r37020 = sqrt(r37019);
        double r37021 = r37016 / r37020;
        double r37022 = r37018 + r37017;
        double r37023 = sqrt(r37022);
        double r37024 = 3.0;
        double r37025 = pow(r37023, r37024);
        double r37026 = cbrt(r37025);
        double r37027 = r37021 / r37026;
        double r37028 = r37027 - r37017;
        double r37029 = r37017 * r37008;
        double r37030 = 5.551115123125783e-17;
        double r37031 = 4.0;
        double r37032 = pow(r37008, r37031);
        double r37033 = r37030 * r37032;
        double r37034 = 0.33333333333333337;
        double r37035 = pow(r37008, r37024);
        double r37036 = r37034 * r37035;
        double r37037 = r37033 + r37036;
        double r37038 = r37029 - r37037;
        double r37039 = r37015 ? r37028 : r37038;
        return r37039;
}

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) < -8.649846695646195e+23 or 4.6290328791112155e-08 < (* -2.0 x)

    1. Initial program 0.1

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

      \[\leadsto \frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied associate-/r*0.1

      \[\leadsto \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    5. Using strategy rm
    6. Applied add-cbrt-cube0.2

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

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

    if -8.649846695646195e+23 < (* -2.0 x) < 4.6290328791112155e-08

    1. Initial program 57.2

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

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

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

Reproduce

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