Average Error: 45.7 → 0.1
Time: 20.0s
Precision: 64
Internal precision: 1408
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -9.950485992669078 \cdot 10^{-09}:\\ \;\;\;\;\frac{1}{1 - e^{-x}}\\ \mathbf{if}\;x \le 0.16631490308113306:\\ \;\;\;\;\frac{1}{x} + \left(\frac{1}{2} + \frac{1}{12} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - e^{-x}}\\ \end{array}\]

Error

Bits error versus x

Target

Original45.7
Comparison30.1
Herbie0.1
\[ \frac{1}{1 - e^{-x}} \]

Derivation

  1. Split input into 2 regimes.
  2. if x < -9.950485992669078e-09 or 0.16631490308113306 < x

    1. Initial program 30.9

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

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

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

    if -9.950485992669078e-09 < x < 0.16631490308113306

    1. Initial program 61.0

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Applied taylor 0.0

      \[\leadsto \frac{1}{x} + \left(\frac{1}{2} + \frac{1}{12} \cdot x\right)\]
    3. Taylor expanded around 0 0.0

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

Runtime

Time bar (total: 20.0s) Debug log

Please include this information when filing a bug report:

herbie shell --seed '#(772101555 1905824529 294602591 2478279198 2123125427 4197813737)'
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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