Average Error: 39.5 → 0.4
Time: 10.8s
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[e^{x} \cdot \frac{1}{\mathsf{expm1}\left(x\right)}\]
\frac{e^{x}}{e^{x} - 1}
e^{x} \cdot \frac{1}{\mathsf{expm1}\left(x\right)}
double f(double x) {
        double r1587669 = x;
        double r1587670 = exp(r1587669);
        double r1587671 = 1.0;
        double r1587672 = r1587670 - r1587671;
        double r1587673 = r1587670 / r1587672;
        return r1587673;
}

double f(double x) {
        double r1587674 = x;
        double r1587675 = exp(r1587674);
        double r1587676 = 1.0;
        double r1587677 = expm1(r1587674);
        double r1587678 = r1587676 / r1587677;
        double r1587679 = r1587675 * r1587678;
        return r1587679;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.5
Target39.2
Herbie0.4
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Initial program 39.5

    \[\frac{e^{x}}{e^{x} - 1}\]
  2. Using strategy rm
  3. Applied expm1-log1p-u39.5

    \[\leadsto \frac{e^{x}}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{x} - 1\right)\right)}}\]
  4. Simplified0.4

    \[\leadsto \frac{e^{x}}{\mathsf{expm1}\left(\color{blue}{x}\right)}\]
  5. Using strategy rm
  6. Applied div-inv0.4

    \[\leadsto \color{blue}{e^{x} \cdot \frac{1}{\mathsf{expm1}\left(x\right)}}\]
  7. Final simplification0.4

    \[\leadsto e^{x} \cdot \frac{1}{\mathsf{expm1}\left(x\right)}\]

Reproduce

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

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

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