Average Error: 40.6 → 0.3
Time: 9.0s
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\frac{e^{x}}{\mathsf{expm1}\left(x\right)}\]
\frac{e^{x}}{e^{x} - 1}
\frac{e^{x}}{\mathsf{expm1}\left(x\right)}
double f(double x) {
        double r1519099 = x;
        double r1519100 = exp(r1519099);
        double r1519101 = 1.0;
        double r1519102 = r1519100 - r1519101;
        double r1519103 = r1519100 / r1519102;
        return r1519103;
}

double f(double x) {
        double r1519104 = x;
        double r1519105 = exp(r1519104);
        double r1519106 = expm1(r1519104);
        double r1519107 = r1519105 / r1519106;
        return r1519107;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.6
Target40.3
Herbie0.3
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Initial program 40.6

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

    \[\leadsto \frac{e^{x}}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{x} - 1\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{e^{x}}{\color{blue}{1 \cdot \mathsf{expm1}\left(x\right)}}\]
  7. Final simplification0.3

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

Reproduce

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

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

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