Average Error: 40.4 → 0.7
Time: 20.3s
Precision: 64
Internal Precision: 1344
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;e^{x} \le 0.9997312861954971:\\ \;\;\;\;\frac{1}{\sqrt[3]{(e^{x} - 1)^*} \cdot \sqrt[3]{(e^{x} - 1)^*}} \cdot \frac{e^{x}}{\sqrt[3]{(e^{x} - 1)^*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} + {\left((\frac{1}{12} \cdot x + \frac{1}{2})_*\right)}^{\left(\frac{1}{3} + \frac{1}{3}\right)} \cdot \sqrt[3]{(\frac{1}{12} \cdot x + \frac{1}{2})_*}\\ \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. Applied simplify0.0

      \[\leadsto \color{blue}{\frac{e^{x}}{(e^{x} - 1)^*}}\]
    3. Using strategy rm
    4. 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)^*}}}\]
    5. Applied *-un-lft-identity0.0

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

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

    if 0.9997312861954971 < (exp x)

    1. Initial program 60.2

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

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

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

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

      \[\leadsto \frac{1}{x} + \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})_*}}\]
    7. Using strategy rm
    8. Applied pow1/31.0

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

      \[\leadsto \frac{1}{x} + \left(\color{blue}{{\left((\frac{1}{12} \cdot x + \frac{1}{2})_*\right)}^{\frac{1}{3}}} \cdot {\left((\frac{1}{12} \cdot x + \frac{1}{2})_*\right)}^{\frac{1}{3}}\right) \cdot \sqrt[3]{(\frac{1}{12} \cdot x + \frac{1}{2})_*}\]
    10. Applied pow-prod-up1.0

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

Runtime

Time bar (total: 20.3s)Debug logProfile

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

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

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