Average Error: 40.1 → 0.7
Time: 26.6s
Precision: 64
Internal Precision: 1408
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;e^{x} \le 0.9999901697358853:\\ \;\;\;\;\frac{e^{x}}{\frac{-1 + {\left(e^{x}\right)}^{3}}{e^{x + x} + \left(e^{x} + 1\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\frac{1}{6} \cdot {x}^{3} + x\right) - \frac{1}{2} \cdot {x}^{2}}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

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

    1. Initial program 0.1

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Using strategy rm
    3. Applied flip3--0.1

      \[\leadsto \frac{e^{x}}{\color{blue}{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)}}}\]
    4. Applied simplify0.1

      \[\leadsto \frac{e^{x}}{\frac{\color{blue}{-1 + {\left(e^{x}\right)}^{3}}}{e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)}}\]
    5. Applied simplify0.1

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

    if 0.9999901697358853 < (exp x)

    1. Initial program 60.2

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

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

      \[\leadsto \frac{1}{\color{blue}{1 - e^{-x}}}\]
    5. Taylor expanded around 0 1.0

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

Runtime

Time bar (total: 26.6s)Debug logProfile

herbie shell --seed '#(1070991898 1055468627 4280279443 640792587 928206309 3646738750)' 
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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