Average Error: 29.7 → 0.0
Time: 16.6s
Precision: 64
Internal Precision: 128
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.007305300802440641:\\ \;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} - 1\\ \mathbf{elif}\;x \le 0.0059308525723558245:\\ \;\;\;\;x + \left(\frac{2}{15} \cdot {x}^{5} - \frac{1}{3} \cdot {x}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{2}{e^{-6 \cdot x} + 1}\right) \cdot \left(e^{-2 \cdot x} \cdot e^{-2 \cdot x} + \left(1 - e^{-2 \cdot x}\right)\right) + -1)_*\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Derivation

  1. Split input into 3 regimes
  2. if x < -0.007305300802440641

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Initial simplification0.0

      \[\leadsto \frac{2}{1 + e^{-2 \cdot x}} - 1\]
    3. Taylor expanded around inf 0.0

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

    if -0.007305300802440641 < x < 0.0059308525723558245

    1. Initial program 59.1

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Initial simplification59.1

      \[\leadsto \frac{2}{1 + e^{-2 \cdot x}} - 1\]
    3. Taylor expanded around inf 59.1

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

      \[\leadsto \color{blue}{\left(x + \frac{2}{15} \cdot {x}^{5}\right) - \frac{1}{3} \cdot {x}^{3}}\]
    5. Using strategy rm
    6. Applied associate--l+0.0

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

    if 0.0059308525723558245 < x

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Initial simplification0.0

      \[\leadsto \frac{2}{1 + e^{-2 \cdot x}} - 1\]
    3. Taylor expanded around inf 0.0

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

      \[\leadsto \frac{2}{\color{blue}{\frac{{\left(e^{-2 \cdot x}\right)}^{3} + {1}^{3}}{e^{-2 \cdot x} \cdot e^{-2 \cdot x} + \left(1 \cdot 1 - e^{-2 \cdot x} \cdot 1\right)}}} - 1\]
    6. Applied associate-/r/0.0

      \[\leadsto \color{blue}{\frac{2}{{\left(e^{-2 \cdot x}\right)}^{3} + {1}^{3}} \cdot \left(e^{-2 \cdot x} \cdot e^{-2 \cdot x} + \left(1 \cdot 1 - e^{-2 \cdot x} \cdot 1\right)\right)} - 1\]
    7. Applied fma-neg0.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.007305300802440641:\\ \;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} - 1\\ \mathbf{elif}\;x \le 0.0059308525723558245:\\ \;\;\;\;x + \left(\frac{2}{15} \cdot {x}^{5} - \frac{1}{3} \cdot {x}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{2}{e^{-6 \cdot x} + 1}\right) \cdot \left(e^{-2 \cdot x} \cdot e^{-2 \cdot x} + \left(1 - e^{-2 \cdot x}\right)\right) + -1)_*\\ \end{array}\]

Runtime

Time bar (total: 16.6s)Debug logProfile

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