Average Error: 41.2 → 0.9
Time: 3.0s
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 r87721 = x;
        double r87722 = exp(r87721);
        double r87723 = 1.0;
        double r87724 = r87722 - r87723;
        double r87725 = r87722 / r87724;
        return r87725;
}

double f(double x) {
        double r87726 = x;
        double r87727 = exp(r87726);
        double r87728 = 2.0;
        double r87729 = pow(r87726, r87728);
        double r87730 = 0.16666666666666666;
        double r87731 = r87726 * r87730;
        double r87732 = 0.5;
        double r87733 = r87731 + r87732;
        double r87734 = r87729 * r87733;
        double r87735 = r87734 + r87726;
        double r87736 = r87727 / r87735;
        return r87736;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 41.2

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

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

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

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

Reproduce

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

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

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