Average Error: 29.4 → 0.1
Time: 12.1s
Precision: 64
Internal Precision: 1344
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;\frac{2}{1 + e^{-2 \cdot x}} - 1 \le -1.0851674992178994 \cdot 10^{-07}:\\ \;\;\;\;\frac{2}{(e^{\log_* (1 + \left(1 + e^{-2 \cdot x}\right))} - 1)^*} - 1\\ \mathbf{elif}\;\frac{2}{1 + e^{-2 \cdot x}} - 1 \le 5.9324951686377854 \cdot 10^{-08}:\\ \;\;\;\;\left(\frac{2}{15} \cdot {x}^{5} + x\right) - {x}^{3} \cdot \frac{1}{3}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{(e^{\log_* (1 + \left(1 + e^{-2 \cdot x}\right))} - 1)^*} - 1\\ \end{array}\]

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 (+ 1 (exp (* -2 x)))) 1) < -1.0851674992178994e-07 or 5.9324951686377854e-08 < (- (/ 2 (+ 1 (exp (* -2 x)))) 1)

    1. Initial program 0.2

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

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

    if -1.0851674992178994e-07 < (- (/ 2 (+ 1 (exp (* -2 x)))) 1) < 5.9324951686377854e-08

    1. Initial program 59.8

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

      \[\leadsto \color{blue}{\left(x + \frac{2}{15} \cdot {x}^{5}\right) - \frac{1}{3} \cdot {x}^{3}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{2}{1 + e^{-2 \cdot x}} - 1 \le -1.0851674992178994 \cdot 10^{-07}:\\ \;\;\;\;\frac{2}{(e^{\log_* (1 + \left(1 + e^{-2 \cdot x}\right))} - 1)^*} - 1\\ \mathbf{elif}\;\frac{2}{1 + e^{-2 \cdot x}} - 1 \le 5.9324951686377854 \cdot 10^{-08}:\\ \;\;\;\;\left(\frac{2}{15} \cdot {x}^{5} + x\right) - {x}^{3} \cdot \frac{1}{3}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{(e^{\log_* (1 + \left(1 + e^{-2 \cdot x}\right))} - 1)^*} - 1\\ \end{array}\]

Runtime

Time bar (total: 12.1s)Debug logProfile

herbie shell --seed 2018216 +o rules:numerics
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))