Average Error: 39.8 → 0.0
Time: 10.6s
Precision: 64
Internal Precision: 1408
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;e^{x} \le 0.9995789316931623:\\ \;\;\;\;\frac{\frac{e^{x}}{1 + \sqrt{e^{x}}}}{\sqrt{e^{x}} - 1}\\ \mathbf{if}\;e^{x} \le 1.0000674656217274:\\ \;\;\;\;\frac{1}{2} + \left(x \cdot \frac{1}{12} + \frac{1}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - e^{-x}}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

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

    1. Initial program 0.0

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

      \[\leadsto \frac{e^{x}}{\color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}} - 1}\]
    4. Applied difference-of-sqr-10.0

      \[\leadsto \frac{e^{x}}{\color{blue}{\left(\sqrt{e^{x}} + 1\right) \cdot \left(\sqrt{e^{x}} - 1\right)}}\]
    5. Applied add-cube-cbrt0.0

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{e^{x}} \cdot \sqrt[3]{e^{x}}\right) \cdot \sqrt[3]{e^{x}}}}{\left(\sqrt{e^{x}} + 1\right) \cdot \left(\sqrt{e^{x}} - 1\right)}\]
    6. Applied times-frac0.0

      \[\leadsto \color{blue}{\frac{\sqrt[3]{e^{x}} \cdot \sqrt[3]{e^{x}}}{\sqrt{e^{x}} + 1} \cdot \frac{\sqrt[3]{e^{x}}}{\sqrt{e^{x}} - 1}}\]

    if 0.9995789316931623 < (exp x) < 1.0000674656217274

    1. Initial program 60.8

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

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

    if 1.0000674656217274 < (exp x)

    1. Initial program 27.1

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

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

      \[\leadsto \frac{1}{\color{blue}{1 - e^{-x}}}\]
    5. Using strategy rm
    6. Applied add-exp-log1.4

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

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

Runtime

Time bar (total: 10.6s)Debug log

herbie shell --seed '#(633950927 2092594946 1442981 2827247922 2812758452 390991499)' 
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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