Average Error: 29.2 → 0.3
Time: 18.0s
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 r30040 = 2.0;
        double r30041 = 1.0;
        double r30042 = -2.0;
        double r30043 = x;
        double r30044 = r30042 * r30043;
        double r30045 = exp(r30044);
        double r30046 = r30041 + r30045;
        double r30047 = r30040 / r30046;
        double r30048 = r30047 - r30041;
        return r30048;
}

double f(double x, double __attribute__((unused)) y) {
        double r30049 = -2.0;
        double r30050 = x;
        double r30051 = r30049 * r30050;
        double r30052 = -7479.799764354564;
        bool r30053 = r30051 <= r30052;
        double r30054 = 8.706977538006746e-11;
        bool r30055 = r30051 <= r30054;
        double r30056 = !r30055;
        bool r30057 = r30053 || r30056;
        double r30058 = 2.0;
        double r30059 = 1.0;
        double r30060 = exp(r30051);
        double r30061 = r30059 + r30060;
        double r30062 = sqrt(r30061);
        double r30063 = r30058 / r30062;
        double r30064 = r30063 / r30062;
        double r30065 = r30064 - r30059;
        double r30066 = r30059 * r30050;
        double r30067 = 5.551115123125783e-17;
        double r30068 = 4.0;
        double r30069 = pow(r30050, r30068);
        double r30070 = r30067 * r30069;
        double r30071 = 0.33333333333333337;
        double r30072 = 3.0;
        double r30073 = pow(r30050, r30072);
        double r30074 = r30071 * r30073;
        double r30075 = r30070 + r30074;
        double r30076 = r30066 - r30075;
        double r30077 = r30057 ? r30065 : r30076;
        return r30077;
}

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))