Average Error: 40.0 → 0.5
Time: 20.7s
Precision: 64
Internal Precision: 128
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0013318219129333287:\\ \;\;\;\;\frac{e^{x}}{\log \left(e^{e^{x} - 1}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{2} + \frac{1}{x}\right) + \frac{1}{12} \cdot x\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -0.0013318219129333287

    1. Initial program 0.0

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Using strategy rm
    3. Applied add-log-exp0.0

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

    if -0.0013318219129333287 < x

    1. Initial program 60.3

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

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

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

Reproduce

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

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

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