Average Error: 29.8 → 0.1
Time: 13.5s
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 -7.201441643009355 \cdot 10^{-05}:\\ \;\;\;\;(\left(\sqrt{\frac{2}{1 + e^{-2 \cdot x}}}\right) \cdot \left(\sqrt{\frac{2}{1 + e^{-2 \cdot x}}}\right) + \left(-1\right))_*\\ \mathbf{elif}\;\frac{2}{1 + e^{-2 \cdot x}} - 1 \le 1.7103594264185684 \cdot 10^{-08}:\\ \;\;\;\;\left(x + \frac{2}{15} \cdot {x}^{5}\right) - \frac{1}{3} \cdot {x}^{3}\\ \mathbf{else}:\\ \;\;\;\;(e^{\log 2 - \log_* (1 + e^{-2 \cdot x})} - 1)^*\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Derivation

  1. Split input into 3 regimes
  2. if (- (/ 2 (+ 1 (exp (* -2 x)))) 1) < -7.201441643009355e-05

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.0

      \[\leadsto \color{blue}{\sqrt{\frac{2}{1 + e^{-2 \cdot x}}} \cdot \sqrt{\frac{2}{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied fma-neg0.0

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

    if -7.201441643009355e-05 < (- (/ 2 (+ 1 (exp (* -2 x)))) 1) < 1.7103594264185684e-08

    1. Initial program 59.6

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

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

    if 1.7103594264185684e-08 < (- (/ 2 (+ 1 (exp (* -2 x)))) 1)

    1. Initial program 0.4

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied add-exp-log0.4

      \[\leadsto \color{blue}{e^{\log \left(\frac{2}{1 + e^{-2 \cdot x}}\right)}} - 1\]
    4. Applied expm1-def0.4

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

      \[\leadsto (e^{\color{blue}{\log 2 - \log_* (1 + e^{-2 \cdot x})}} - 1)^*\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.1

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

Runtime

Time bar (total: 13.5s)Debug logProfile

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