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

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.9
Target39.4
Herbie0.9
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (exp x) (- (exp x) 1)) < 1.0000265219853308

    1. Initial program 0.9

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

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

    if 1.0000265219853308 < (/ (exp x) (- (exp x) 1))

    1. Initial program 61.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{x}}{e^{x} - 1} \le 1.0000265219853308:\\ \;\;\;\;\frac{e^{x}}{e^{x} - 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{12} \cdot x + \left(\frac{1}{2} + \frac{1}{x}\right)\\ \end{array}\]

Runtime

Time bar (total: 33.1s)Debug logProfile

herbie shell --seed 2018230 
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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