Average Error: 29.0 → 0.1
Time: 11.1s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.16694293117624887 \lor \neg \left(-2 \cdot x \le 1.3471487435038969 \cdot 10^{-8}\right):\\ \;\;\;\;\left(\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1\right) \cdot \frac{1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(4.996 \cdot 10^{-16} \cdot {x}^{4} + 0.33333333333333348 \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -0.16694293117624887 \lor \neg \left(-2 \cdot x \le 1.3471487435038969 \cdot 10^{-8}\right):\\
\;\;\;\;\left(\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1\right) \cdot \frac{1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot x - \left(4.996 \cdot 10^{-16} \cdot {x}^{4} + 0.33333333333333348 \cdot {x}^{3}\right)\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r46257 = 2.0;
        double r46258 = 1.0;
        double r46259 = -2.0;
        double r46260 = x;
        double r46261 = r46259 * r46260;
        double r46262 = exp(r46261);
        double r46263 = r46258 + r46262;
        double r46264 = r46257 / r46263;
        double r46265 = r46264 - r46258;
        return r46265;
}

double f(double x, double __attribute__((unused)) y) {
        double r46266 = -2.0;
        double r46267 = x;
        double r46268 = r46266 * r46267;
        double r46269 = -0.16694293117624887;
        bool r46270 = r46268 <= r46269;
        double r46271 = 1.3471487435038969e-08;
        bool r46272 = r46268 <= r46271;
        double r46273 = !r46272;
        bool r46274 = r46270 || r46273;
        double r46275 = 2.0;
        double r46276 = 1.0;
        double r46277 = exp(r46268);
        double r46278 = r46276 + r46277;
        double r46279 = r46275 / r46278;
        double r46280 = r46279 * r46279;
        double r46281 = r46276 * r46276;
        double r46282 = r46280 - r46281;
        double r46283 = 1.0;
        double r46284 = r46279 + r46276;
        double r46285 = r46283 / r46284;
        double r46286 = r46282 * r46285;
        double r46287 = r46276 * r46267;
        double r46288 = 4.996003610813204e-16;
        double r46289 = 4.0;
        double r46290 = pow(r46267, r46289);
        double r46291 = r46288 * r46290;
        double r46292 = 0.3333333333333335;
        double r46293 = 3.0;
        double r46294 = pow(r46267, r46293);
        double r46295 = r46292 * r46294;
        double r46296 = r46291 + r46295;
        double r46297 = r46287 - r46296;
        double r46298 = r46274 ? r46286 : r46297;
        return r46298;
}

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) < -0.16694293117624887 or 1.3471487435038969e-08 < (* -2.0 x)

    1. Initial program 0.2

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

      \[\leadsto \color{blue}{\frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}}\]
    4. Using strategy rm
    5. Applied div-inv0.2

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

    if -0.16694293117624887 < (* -2.0 x) < 1.3471487435038969e-08

    1. Initial program 59.4

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

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

      \[\leadsto \color{blue}{1 \cdot x - \left(4.996 \cdot 10^{-16} \cdot {x}^{4} + 0.33333333333333348 \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 -0.16694293117624887 \lor \neg \left(-2 \cdot x \le 1.3471487435038969 \cdot 10^{-8}\right):\\ \;\;\;\;\left(\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1\right) \cdot \frac{1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(4.996 \cdot 10^{-16} \cdot {x}^{4} + 0.33333333333333348 \cdot {x}^{3}\right)\\ \end{array}\]

Reproduce

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