Average Error: 40.2 → 0.6
Time: 1.1m
Precision: 64
Internal Precision: 1408
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;\sqrt[3]{{\left(\frac{e^{x}}{(e^{x} - 1)^*}\right)}^{3}} \le -3.1402664742376494 \cdot 10^{-307}:\\ \;\;\;\;{\left((x \cdot \left((\frac{1}{96} \cdot x + \frac{1}{16})_*\right) + \frac{1}{8})_*\right)}^{\frac{1}{3}} + \frac{1}{x}\\ \mathbf{if}\;\sqrt[3]{{\left(\frac{e^{x}}{(e^{x} - 1)^*}\right)}^{3}} \le 1415.3585406381567:\\ \;\;\;\;\sqrt[3]{{\left(\frac{e^{x}}{(e^{x} - 1)^*}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;{\left((x \cdot \left((\frac{1}{96} \cdot x + \frac{1}{16})_*\right) + \frac{1}{8})_*\right)}^{\frac{1}{3}} + \frac{1}{x}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (cbrt (pow (/ (exp x) (expm1 x)) 3)) < -3.1402664742376494e-307 or 1415.3585406381567 < (cbrt (pow (/ (exp x) (expm1 x)) 3))

    1. Initial program 60.2

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Applied simplify0.6

      \[\leadsto \color{blue}{\frac{e^{x}}{(e^{x} - 1)^*}}\]
    3. Taylor expanded around 0 0.9

      \[\leadsto \color{blue}{\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)}\]
    4. Applied simplify0.9

      \[\leadsto \color{blue}{\frac{1}{x} + (\frac{1}{12} \cdot x + \frac{1}{2})_*}\]
    5. Using strategy rm
    6. Applied add-cbrt-cube0.9

      \[\leadsto \frac{1}{x} + \color{blue}{\sqrt[3]{\left((\frac{1}{12} \cdot x + \frac{1}{2})_* \cdot (\frac{1}{12} \cdot x + \frac{1}{2})_*\right) \cdot (\frac{1}{12} \cdot x + \frac{1}{2})_*}}\]
    7. Applied simplify0.9

      \[\leadsto \frac{1}{x} + \sqrt[3]{\color{blue}{{\left((x \cdot \frac{1}{12} + \frac{1}{2})_*\right)}^{3}}}\]
    8. Taylor expanded around 0 0.9

      \[\leadsto \frac{1}{x} + \sqrt[3]{\color{blue}{\frac{1}{96} \cdot {x}^{2} + \left(\frac{1}{8} + \frac{1}{16} \cdot x\right)}}\]
    9. Applied simplify0.9

      \[\leadsto \color{blue}{\sqrt[3]{(x \cdot \left((\frac{1}{96} \cdot x + \frac{1}{16})_*\right) + \frac{1}{8})_*} + \frac{1}{x}}\]
    10. Using strategy rm
    11. Applied pow1/30.9

      \[\leadsto \color{blue}{{\left((x \cdot \left((\frac{1}{96} \cdot x + \frac{1}{16})_*\right) + \frac{1}{8})_*\right)}^{\frac{1}{3}}} + \frac{1}{x}\]

    if -3.1402664742376494e-307 < (cbrt (pow (/ (exp x) (expm1 x)) 3)) < 1415.3585406381567

    1. Initial program 0.0

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Applied simplify0.0

      \[\leadsto \color{blue}{\frac{e^{x}}{(e^{x} - 1)^*}}\]
    3. Using strategy rm
    4. Applied add-cbrt-cube0.0

      \[\leadsto \frac{e^{x}}{\color{blue}{\sqrt[3]{\left((e^{x} - 1)^* \cdot (e^{x} - 1)^*\right) \cdot (e^{x} - 1)^*}}}\]
    5. Applied add-cbrt-cube0.2

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(e^{x} \cdot e^{x}\right) \cdot e^{x}}}}{\sqrt[3]{\left((e^{x} - 1)^* \cdot (e^{x} - 1)^*\right) \cdot (e^{x} - 1)^*}}\]
    6. Applied cbrt-undiv0.2

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

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{e^{x}}{(e^{x} - 1)^*}\right)}^{3}}}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 1.1m)Debug logProfile

herbie shell --seed '#(1070960995 739739648 2531964651 3069671617 351857262 3877178482)' +o rules:numerics
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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