Average Error: 39.8 → 0.0
Time: 9.1s
Precision: 64
Internal Precision: 1408
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0020821440085700095:\\ \;\;\;\;\frac{\frac{e^{x}}{1 + \sqrt{e^{x}}}}{\sqrt{e^{x}} - 1}\\ \mathbf{if}\;x \le 0.0018970338561144866:\\ \;\;\;\;\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 x < -0.0020821440085700095

    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.0020821440085700095 < x < 0.0018970338561144866

    1. Initial program 60.6

      \[\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 0.0018970338561144866 < x

    1. Initial program 28.8

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

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

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

      \[\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}\;x \le -0.0020821440085700095:\\ \;\;\;\;\frac{\frac{e^{x}}{1 + \sqrt{e^{x}}}}{\sqrt{e^{x}} - 1}\\ \mathbf{if}\;x \le 0.0018970338561144866:\\ \;\;\;\;\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: 9.1s)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)))