Average Error: 41.2 → 1.1
Time: 12.1s
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\frac{e^{x}}{{x}^{2} \cdot \left(x \cdot \frac{1}{6} + \frac{1}{2}\right) + x}\]
\frac{e^{x}}{e^{x} - 1}
\frac{e^{x}}{{x}^{2} \cdot \left(x \cdot \frac{1}{6} + \frac{1}{2}\right) + x}
double f(double x) {
        double r37695 = x;
        double r37696 = exp(r37695);
        double r37697 = 1.0;
        double r37698 = r37696 - r37697;
        double r37699 = r37696 / r37698;
        return r37699;
}

double f(double x) {
        double r37700 = x;
        double r37701 = exp(r37700);
        double r37702 = 2.0;
        double r37703 = pow(r37700, r37702);
        double r37704 = 0.16666666666666666;
        double r37705 = r37700 * r37704;
        double r37706 = 0.5;
        double r37707 = r37705 + r37706;
        double r37708 = r37703 * r37707;
        double r37709 = r37708 + r37700;
        double r37710 = r37701 / r37709;
        return r37710;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original41.2
Target40.8
Herbie1.1
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Initial program 41.2

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

    \[\leadsto \frac{e^{x}}{\color{blue}{\frac{1}{2} \cdot {x}^{2} + \left(\frac{1}{6} \cdot {x}^{3} + x\right)}}\]
  3. Simplified1.1

    \[\leadsto \frac{e^{x}}{\color{blue}{{x}^{2} \cdot \left(x \cdot \frac{1}{6} + \frac{1}{2}\right) + x}}\]
  4. Final simplification1.1

    \[\leadsto \frac{e^{x}}{{x}^{2} \cdot \left(x \cdot \frac{1}{6} + \frac{1}{2}\right) + x}\]

Reproduce

herbie shell --seed 2019297 
(FPCore (x)
  :name "expq2 (section 3.11)"
  :precision binary64

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

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