Average Error: 40.6 → 0.4
Time: 8.3s
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 r1333867 = x;
        double r1333868 = exp(r1333867);
        double r1333869 = 1.0;
        double r1333870 = r1333868 - r1333869;
        double r1333871 = r1333868 / r1333870;
        return r1333871;
}

double f(double x) {
        double r1333872 = x;
        double r1333873 = exp(r1333872);
        double r1333874 = 1.0;
        double r1333875 = expm1(r1333872);
        double r1333876 = r1333874 / r1333875;
        double r1333877 = r1333873 * r1333876;
        return r1333877;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.6
Target40.2
Herbie0.4
\[\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.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 2019156 +o rules:numerics
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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