Average Error: 40.3 → 0.6
Time: 8.3s
Precision: 64
Internal Precision: 128
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0015802000072994322:\\ \;\;\;\;\frac{\sqrt[3]{e^{x}} \cdot \sqrt[3]{e^{x}}}{\frac{e^{x} - 1}{\sqrt[3]{e^{x}}}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{12} + \left(\frac{1}{x} + \frac{1}{2}\right)\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -0.0015802000072994322

    1. Initial program 0.0

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Using strategy rm
    3. 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}}}}{e^{x} - 1}\]
    4. Applied associate-/l*0.0

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

    if -0.0015802000072994322 < x

    1. Initial program 60.1

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

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

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

Reproduce

herbie shell --seed 2019093 
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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