Average Error: 40.0 → 0.4
Time: 16.4s
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 r2650202 = x;
        double r2650203 = exp(r2650202);
        double r2650204 = 1.0;
        double r2650205 = r2650203 - r2650204;
        double r2650206 = r2650203 / r2650205;
        return r2650206;
}

double f(double x) {
        double r2650207 = x;
        double r2650208 = exp(r2650207);
        double r2650209 = 1.0;
        double r2650210 = expm1(r2650207);
        double r2650211 = r2650209 / r2650210;
        double r2650212 = r2650208 * r2650211;
        return r2650212;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.0
Target39.6
Herbie0.4
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Initial program 40.0

    \[\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 div-inv0.4

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

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

Reproduce

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

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

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