Average Error: 40.3 → 0.7
Time: 8.2s
Precision: 64
Internal Precision: 1344
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;e^{x} \le 0.1475328807975362:\\ \;\;\;\;\frac{1}{1 - e^{-x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)\\ \end{array}\]

Error

Bits error versus x

Try it out

  1. Inputs

  2. Original Output:

    Herbie Output:

Target

Original40.3
Target39.8
Herbie0.7
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Split input into 2 regimes
  2. if (exp x) < 0.1475328807975362

    1. Initial program 0.0

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Using strategy rm
    3. Applied clear-num0.0

      \[\leadsto \color{blue}{\frac{1}{\frac{e^{x} - 1}{e^{x}}}}\]
    4. Applied simplify0.0

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

    if 0.1475328807975362 < (exp x)

    1. Initial program 60.0

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

      \[\leadsto \color{blue}{\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 8.2s)Debug logProfile

herbie shell --seed '#(1072361757 3390613284 2339397988 1175251238 145061547 3101881848)' 
(FPCore (x)
  :name "expq2 (section 3.11)"

  :herbie-target
  (/ 1 (- 1 (exp (- x))))

  (/ (exp x) (- (exp x) 1)))