Average Error: 39.7 → 0.6
Time: 1.4m
Precision: 64
Internal Precision: 1344
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;e^{x} \le 0.9919924066116195:\\ \;\;\;\;\frac{e^{x}}{\left(\sqrt{e^{x}} - 1\right) \cdot \left(\sqrt{e^{x}} + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} + x \cdot \frac{1}{12}\right) + \frac{1}{2}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.7
Target39.3
Herbie0.6
\[\frac{1}{1 - e^{-x}}\]

Derivation

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

    1. Initial program 0.0

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

      \[\leadsto \frac{e^{x}}{\color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}} - 1}\]
    4. Applied difference-of-sqr-10.0

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

    if 0.9919924066116195 < (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.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{x} \le 0.9919924066116195:\\ \;\;\;\;\frac{e^{x}}{\left(\sqrt{e^{x}} - 1\right) \cdot \left(\sqrt{e^{x}} + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} + x \cdot \frac{1}{12}\right) + \frac{1}{2}\\ \end{array}\]

Runtime

Time bar (total: 1.4m)Debug logProfile

herbie shell --seed 2018214 
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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