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

Error

Bits error versus x

Bits error versus y

Derivation

  1. Split input into 2 regimes
  2. if x < -0.007038209077950365 or 0.007337868619411509 < x

    1. Initial program 0.0

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

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

    if -0.007038209077950365 < x < 0.007337868619411509

    1. Initial program 58.9

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

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

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

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

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

Reproduce

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