Average Error: 40.1 → 0.3
Time: 2.0m
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\frac{1}{\frac{\mathsf{expm1}\left(x\right)}{e^{x}}}\]
\frac{e^{x}}{e^{x} - 1}
\frac{1}{\frac{\mathsf{expm1}\left(x\right)}{e^{x}}}
double f(double x) {
        double r6113690 = x;
        double r6113691 = exp(r6113690);
        double r6113692 = 1.0;
        double r6113693 = r6113691 - r6113692;
        double r6113694 = r6113691 / r6113693;
        return r6113694;
}

double f(double x) {
        double r6113695 = 1.0;
        double r6113696 = x;
        double r6113697 = expm1(r6113696);
        double r6113698 = exp(r6113696);
        double r6113699 = r6113697 / r6113698;
        double r6113700 = r6113695 / r6113699;
        return r6113700;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 40.1

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

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

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

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

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

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

Reproduce

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

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

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