Average Error: 29.2 → 0.1
Time: 19.5s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -1.0646225484162213 \lor \neg \left(-2 \cdot x \le 7.02017225425806434 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3}}{1 \cdot 1 + \frac{2}{1 + e^{-2 \cdot x}} \cdot \left(\frac{2}{1 + e^{-2 \cdot x}} + 1\right)}\\ \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 -1.0646225484162213 \lor \neg \left(-2 \cdot x \le 7.02017225425806434 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3}}{1 \cdot 1 + \frac{2}{1 + e^{-2 \cdot x}} \cdot \left(\frac{2}{1 + e^{-2 \cdot x}} + 1\right)}\\

\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 r44247 = 2.0;
        double r44248 = 1.0;
        double r44249 = -2.0;
        double r44250 = x;
        double r44251 = r44249 * r44250;
        double r44252 = exp(r44251);
        double r44253 = r44248 + r44252;
        double r44254 = r44247 / r44253;
        double r44255 = r44254 - r44248;
        return r44255;
}

double f(double x, double __attribute__((unused)) y) {
        double r44256 = -2.0;
        double r44257 = x;
        double r44258 = r44256 * r44257;
        double r44259 = -1.0646225484162213;
        bool r44260 = r44258 <= r44259;
        double r44261 = 7.020172254258064e-06;
        bool r44262 = r44258 <= r44261;
        double r44263 = !r44262;
        bool r44264 = r44260 || r44263;
        double r44265 = 2.0;
        double r44266 = 1.0;
        double r44267 = exp(r44258);
        double r44268 = r44266 + r44267;
        double r44269 = r44265 / r44268;
        double r44270 = 3.0;
        double r44271 = pow(r44269, r44270);
        double r44272 = pow(r44266, r44270);
        double r44273 = r44271 - r44272;
        double r44274 = r44266 * r44266;
        double r44275 = r44269 + r44266;
        double r44276 = r44269 * r44275;
        double r44277 = r44274 + r44276;
        double r44278 = r44273 / r44277;
        double r44279 = r44266 * r44257;
        double r44280 = 5.551115123125783e-17;
        double r44281 = 4.0;
        double r44282 = pow(r44257, r44281);
        double r44283 = r44280 * r44282;
        double r44284 = 0.33333333333333337;
        double r44285 = pow(r44257, r44270);
        double r44286 = r44284 * r44285;
        double r44287 = r44283 + r44286;
        double r44288 = r44279 - r44287;
        double r44289 = r44264 ? r44278 : r44288;
        return r44289;
}

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) < -1.0646225484162213 or 7.020172254258064e-06 < (* -2.0 x)

    1. Initial program 0.1

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

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

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

    if -1.0646225484162213 < (* -2.0 x) < 7.020172254258064e-06

    1. Initial program 59.2

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

      \[\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.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -1.0646225484162213 \lor \neg \left(-2 \cdot x \le 7.02017225425806434 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3}}{1 \cdot 1 + \frac{2}{1 + e^{-2 \cdot x}} \cdot \left(\frac{2}{1 + e^{-2 \cdot x}} + 1\right)}\\ \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 2019199 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))