Average Error: 29.2 → 0.3
Time: 18.2s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -7479.799764354564103996381163597106933594 \lor \neg \left(-2 \cdot x \le 8.70697753800674634828830743637595283857 \cdot 10^{-11}\right):\\ \;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 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 -7479.799764354564103996381163597106933594 \lor \neg \left(-2 \cdot x \le 8.70697753800674634828830743637595283857 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 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 r29905 = 2.0;
        double r29906 = 1.0;
        double r29907 = -2.0;
        double r29908 = x;
        double r29909 = r29907 * r29908;
        double r29910 = exp(r29909);
        double r29911 = r29906 + r29910;
        double r29912 = r29905 / r29911;
        double r29913 = r29912 - r29906;
        return r29913;
}

double f(double x, double __attribute__((unused)) y) {
        double r29914 = -2.0;
        double r29915 = x;
        double r29916 = r29914 * r29915;
        double r29917 = -7479.799764354564;
        bool r29918 = r29916 <= r29917;
        double r29919 = 8.706977538006746e-11;
        bool r29920 = r29916 <= r29919;
        double r29921 = !r29920;
        bool r29922 = r29918 || r29921;
        double r29923 = 2.0;
        double r29924 = 1.0;
        double r29925 = exp(r29916);
        double r29926 = r29924 + r29925;
        double r29927 = sqrt(r29926);
        double r29928 = r29923 / r29927;
        double r29929 = r29928 / r29927;
        double r29930 = r29929 - r29924;
        double r29931 = r29924 * r29915;
        double r29932 = 5.551115123125783e-17;
        double r29933 = 4.0;
        double r29934 = pow(r29915, r29933);
        double r29935 = r29932 * r29934;
        double r29936 = 0.33333333333333337;
        double r29937 = 3.0;
        double r29938 = pow(r29915, r29937);
        double r29939 = r29936 * r29938;
        double r29940 = r29935 + r29939;
        double r29941 = r29931 - r29940;
        double r29942 = r29922 ? r29930 : r29941;
        return r29942;
}

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) < -7479.799764354564 or 8.706977538006746e-11 < (* -2.0 x)

    1. Initial program 0.3

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

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

      \[\leadsto \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1\]

    if -7479.799764354564 < (* -2.0 x) < 8.706977538006746e-11

    1. Initial program 59.1

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

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

      \[\leadsto \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    5. Taylor expanded around 0 0.4

      \[\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 simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -7479.799764354564103996381163597106933594 \lor \neg \left(-2 \cdot x \le 8.70697753800674634828830743637595283857 \cdot 10^{-11}\right):\\ \;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 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 2019326 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  :precision binary64
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))