Average Error: 39.8 → 0.4
Time: 53.3s
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\frac{\frac{1}{\mathsf{expm1}\left(x\right)}}{\frac{1}{e^{x}}}\]
\frac{e^{x}}{e^{x} - 1}
\frac{\frac{1}{\mathsf{expm1}\left(x\right)}}{\frac{1}{e^{x}}}
double f(double x) {
        double r6472580 = x;
        double r6472581 = exp(r6472580);
        double r6472582 = 1.0;
        double r6472583 = r6472581 - r6472582;
        double r6472584 = r6472581 / r6472583;
        return r6472584;
}

double f(double x) {
        double r6472585 = 1.0;
        double r6472586 = x;
        double r6472587 = expm1(r6472586);
        double r6472588 = r6472585 / r6472587;
        double r6472589 = exp(r6472586);
        double r6472590 = r6472585 / r6472589;
        double r6472591 = r6472588 / r6472590;
        return r6472591;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 39.8

    \[\frac{e^{x}}{e^{x} - 1}\]
  2. Using strategy rm
  3. Applied expm1-def0.4

    \[\leadsto \frac{e^{x}}{\color{blue}{\mathsf{expm1}\left(x\right)}}\]
  4. Using strategy rm
  5. Applied *-un-lft-identity0.4

    \[\leadsto \frac{\color{blue}{1 \cdot e^{x}}}{\mathsf{expm1}\left(x\right)}\]
  6. Applied associate-/l*0.4

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

    \[\leadsto \frac{1}{\color{blue}{\mathsf{expm1}\left(x\right) \cdot \frac{1}{e^{x}}}}\]
  9. Applied associate-/r*0.4

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

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

Reproduce

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

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

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