Average Error: 45.5 → 0.2
Time: 12.6s
Precision: 64
Internal precision: 1408
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.3260991409638585 \cdot 10^{-12}:\\ \;\;\;\;\frac{e^{x}}{{\left(e^{x}\right)}^3 - 1} \cdot \left({\left(e^{x}\right)}^2 + \left({1}^2 + e^{x} \cdot 1\right)\right)\\ \mathbf{if}\;x \le 7.988163388129748:\\ \;\;\;\;\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1 - {\left(e^{-x}\right)}^3}{\left(1 + {\left(e^{2}\right)}^{\left(-x\right)}\right) + e^{-x}}}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 3 regimes.
  2. if x < -1.3260991409638585e-12

    1. Initial program 0.6

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

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

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

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

    if -1.3260991409638585e-12 < x < 7.988163388129748

    1. Initial program 61.0

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

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

      \[\leadsto \color{blue}{\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)}\]

    if 7.988163388129748 < x

    1. Initial program 61.7

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

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

      \[\leadsto \frac{1}{\color{blue}{1 - e^{-x}}}\]
    5. Using strategy rm
    6. Applied flip3-- 0.0

      \[\leadsto \frac{1}{\color{blue}{\frac{{1}^{3} - {\left(e^{-x}\right)}^{3}}{{1}^2 + \left({\left(e^{-x}\right)}^2 + 1 \cdot e^{-x}\right)}}}\]
    7. Applied simplify 0.0

      \[\leadsto \frac{1}{\frac{\color{blue}{1 - {\left(e^{-x}\right)}^3}}{{1}^2 + \left({\left(e^{-x}\right)}^2 + 1 \cdot e^{-x}\right)}}\]
    8. Applied simplify 0.0

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

Runtime

Time bar (total: 12.6s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064524629 4159152179 2999149171 575749698 4006532819 692958815)'
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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