Average Error: 39.8 → 0.4
Time: 10.9s
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 r1752919 = x;
        double r1752920 = exp(r1752919);
        double r1752921 = 1.0;
        double r1752922 = r1752920 - r1752921;
        double r1752923 = r1752920 / r1752922;
        return r1752923;
}

double f(double x) {
        double r1752924 = x;
        double r1752925 = exp(r1752924);
        double r1752926 = 1.0;
        double r1752927 = expm1(r1752924);
        double r1752928 = r1752926 / r1752927;
        double r1752929 = r1752925 * r1752928;
        return r1752929;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.8
Target39.4
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-log1p-u39.8

    \[\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 2019155 +o rules:numerics
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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