Average Error: 29.5 → 0.1
Time: 27.3s
Precision: 64
Internal Precision: 1408
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;1 + e^{-2 \cdot x} \le 1.9886528426585757:\\ \;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}} - 1\\ \mathbf{if}\;1 + e^{-2 \cdot x} \le 2.00000000509342:\\ \;\;\;\;\left(\frac{2}{15} \cdot {x}^{5} + x\right) - \frac{1}{3} \cdot {x}^{3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{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 (+ 1 (exp (* -2 x))) < 1.9886528426585757

    1. Initial program 0.0

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

      \[\leadsto \frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied associate-/r*0.0

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

    if 1.9886528426585757 < (+ 1 (exp (* -2 x))) < 2.00000000509342

    1. Initial program 59.5

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

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

    if 2.00000000509342 < (+ 1 (exp (* -2 x)))

    1. Initial program 0.4

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

      \[\leadsto \frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied associate-/r*0.4

      \[\leadsto \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 27.3s)Debug logProfile

herbie shell --seed '#(1070258749 1877548225 2229079127 1588002776 3179087814 1886870650)' +o rules:numerics
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))