Average Error: 40.1 → 0.4
Time: 16.6s
Precision: 64
Internal Precision: 1344
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;(e^{\log_* (1 + \frac{e^{x}}{(e^{x} - 1)^*})} - 1)^* \le 34.22285332125396:\\ \;\;\;\;(e^{\log_* (1 + \frac{e^{x}}{(e^{x} - 1)^*})} - 1)^*\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\sqrt[3]{(\frac{1}{12} \cdot x + \frac{1}{2})_*} \cdot \sqrt[3]{\sqrt{(\frac{1}{12} \cdot x + \frac{1}{2})_*}}\right) \cdot \sqrt[3]{\sqrt{(\frac{1}{12} \cdot x + \frac{1}{2})_*}}\right) \cdot \sqrt[3]{(\frac{1}{12} \cdot x + \frac{1}{2})_*} + \frac{1}{x}\\ \end{array}\]

Error

Bits error versus x

Target

Original40.1
Target39.7
Herbie0.4
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Split input into 2 regimes
  2. if (expm1 (log1p (/ (exp x) (expm1 x)))) < 34.22285332125396

    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 expm1-log1p-u0.0

      \[\leadsto \color{blue}{(e^{\log_* (1 + \frac{e^{x}}{(e^{x} - 1)^*})} - 1)^*}\]

    if 34.22285332125396 < (expm1 (log1p (/ (exp x) (expm1 x))))

    1. Initial program 60.2

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

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

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

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{(\frac{1}{12} \cdot x + \frac{1}{2})_*} \cdot \sqrt[3]{(\frac{1}{12} \cdot x + \frac{1}{2})_*}\right) \cdot \sqrt[3]{(\frac{1}{12} \cdot x + \frac{1}{2})_*}} + \frac{1}{x}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt0.6

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

      \[\leadsto \left(\sqrt[3]{(\frac{1}{12} \cdot x + \frac{1}{2})_*} \cdot \color{blue}{\left(\sqrt[3]{\sqrt{(\frac{1}{12} \cdot x + \frac{1}{2})_*}} \cdot \sqrt[3]{\sqrt{(\frac{1}{12} \cdot x + \frac{1}{2})_*}}\right)}\right) \cdot \sqrt[3]{(\frac{1}{12} \cdot x + \frac{1}{2})_*} + \frac{1}{x}\]
    10. Applied associate-*r*0.6

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

Runtime

Time bar (total: 16.6s)Debug logProfile

herbie shell --seed 2019053 +o rules:numerics
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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