Average Error: 29.1 → 0.3
Time: 4.4s
Precision: binary64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -57.4003265680906836 \lor \neg \left(-2 \cdot x \le 1.993059886080994 \cdot 10^{-13}\right):\\ \;\;\;\;\frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{\frac{\frac{2}{\frac{{\left(e^{-2 \cdot x} + 1\right)}^{2}}{2}} + \left(-1 \cdot 1\right)}{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Derivation

  1. Split input into 2 regimes
  2. if (* -2.0 x) < -57.4003265680906836 or 1.993059886080994e-13 < (* -2.0 x)

    1. Initial program 0.3

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

      \[\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 flip-+0.3

      \[\leadsto \frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{\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}}}\]
    6. Simplified0.3

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

    if -57.4003265680906836 < (* -2.0 x) < 1.993059886080994e-13

    1. Initial program 59.2

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

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

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