Average Error: 29.6 → 1.3
Time: 19.4s
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{2}{e^{-2 \cdot x} + 1} - 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - {x}^{3} \cdot \left(0.3333333333333333703407674875052180141211 + 5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x\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{2}{e^{-2 \cdot x} + 1} - 1\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r41042 = 2.0;
        double r41043 = 1.0;
        double r41044 = -2.0;
        double r41045 = x;
        double r41046 = r41044 * r41045;
        double r41047 = exp(r41046);
        double r41048 = r41043 + r41047;
        double r41049 = r41042 / r41048;
        double r41050 = r41049 - r41043;
        return r41050;
}

double f(double x, double __attribute__((unused)) y) {
        double r41051 = -2.0;
        double r41052 = x;
        double r41053 = r41051 * r41052;
        double r41054 = -8.649846695646195e+23;
        bool r41055 = r41053 <= r41054;
        double r41056 = 4.6290328791112155e-08;
        bool r41057 = r41053 <= r41056;
        double r41058 = !r41057;
        bool r41059 = r41055 || r41058;
        double r41060 = 2.0;
        double r41061 = exp(r41053);
        double r41062 = 1.0;
        double r41063 = r41061 + r41062;
        double r41064 = r41060 / r41063;
        double r41065 = r41064 - r41062;
        double r41066 = r41062 * r41052;
        double r41067 = 3.0;
        double r41068 = pow(r41052, r41067);
        double r41069 = 0.33333333333333337;
        double r41070 = 5.551115123125783e-17;
        double r41071 = r41070 * r41052;
        double r41072 = r41069 + r41071;
        double r41073 = r41068 * r41072;
        double r41074 = r41066 - r41073;
        double r41075 = r41059 ? r41065 : r41074;
        return r41075;
}

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 *-un-lft-identity0.1

      \[\leadsto \frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - \color{blue}{1 \cdot 1}\]
    7. Applied *-un-lft-identity0.1

      \[\leadsto \color{blue}{1 \cdot \frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1 \cdot 1\]
    8. Applied distribute-lft-out--0.1

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

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

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

    1. Initial program 57.2

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

      \[\leadsto \frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied associate-/r*58.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 *-un-lft-identity58.1

      \[\leadsto \frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - \color{blue}{1 \cdot 1}\]
    7. Applied *-un-lft-identity58.1

      \[\leadsto \color{blue}{1 \cdot \frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1 \cdot 1\]
    8. Applied distribute-lft-out--58.1

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

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{2}{e^{-2 \cdot x} + 1} - 1\right)}\]
    10. Taylor expanded around 0 2.3

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

      \[\leadsto 1 \cdot \color{blue}{\left(1 \cdot x - {x}^{3} \cdot \left(0.3333333333333333703407674875052180141211 + 5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x\right)\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{2}{e^{-2 \cdot x} + 1} - 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - {x}^{3} \cdot \left(0.3333333333333333703407674875052180141211 + 5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x\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))