Average Error: 40.4 → 0.7
Time: 26.2s
Precision: 64
Internal Precision: 1344
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;e^{x} \le 0.9997312861954971:\\ \;\;\;\;\left(\sqrt[3]{e^{x}} \cdot \sqrt[3]{e^{x}}\right) \cdot \frac{\sqrt[3]{e^{x}}}{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.4
Target39.8
Herbie0.7
\[\frac{1}{1 - e^{-x}}\]

Derivation

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

    1. Initial program 0.0

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.0

      \[\leadsto \frac{e^{x}}{\color{blue}{1 \cdot \left(e^{x} - 1\right)}}\]
    4. 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}}}}{1 \cdot \left(e^{x} - 1\right)}\]
    5. Applied times-frac0.0

      \[\leadsto \color{blue}{\frac{\sqrt[3]{e^{x}} \cdot \sqrt[3]{e^{x}}}{1} \cdot \frac{\sqrt[3]{e^{x}}}{e^{x} - 1}}\]
    6. Applied simplify0.0

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

    if 0.9997312861954971 < (exp x)

    1. Initial program 60.2

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

      \[\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: 26.2s)Debug logProfile

herbie shell --seed '#(1072107073 2127697367 3936270018 2300570620 2134894798 4023771849)' 
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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