Average Error: 40.3 → 0.6
Time: 1.6m
Precision: 64
Internal Precision: 1344
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;e^{x} \le 0.9989605912940498:\\ \;\;\;\;\frac{e^{x}}{\left(\sqrt[3]{e^{x} - 1} \cdot \sqrt[3]{e^{x} - 1}\right) \cdot \sqrt[3]{e^{x} - 1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\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 (exp x) < 0.9989605912940498

    1. Initial program 0.0

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

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

    if 0.9989605912940498 < (exp x)

    1. Initial program 60.3

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

      \[\leadsto \frac{e^{x}}{\color{blue}{\frac{1}{2} \cdot {x}^{2} + \left(\frac{1}{6} \cdot {x}^{3} + x\right)}}\]
    3. Taylor expanded around 0 0.9

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

Runtime

Time bar (total: 1.6m)Debug logProfile

herbie shell --seed '#(1071948828 1180510430 2986424009 997076509 406109801 420189285)' 
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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