Average Error: 40.4 → 0.4
Time: 14.2s
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\frac{e^{x} + 1}{\mathsf{expm1}\left(\left(x + x\right)\right)} \cdot e^{x}\]
\frac{e^{x}}{e^{x} - 1}
\frac{e^{x} + 1}{\mathsf{expm1}\left(\left(x + x\right)\right)} \cdot e^{x}
double f(double x) {
        double r3148445 = x;
        double r3148446 = exp(r3148445);
        double r3148447 = 1.0;
        double r3148448 = r3148446 - r3148447;
        double r3148449 = r3148446 / r3148448;
        return r3148449;
}

double f(double x) {
        double r3148450 = x;
        double r3148451 = exp(r3148450);
        double r3148452 = 1.0;
        double r3148453 = r3148451 + r3148452;
        double r3148454 = r3148450 + r3148450;
        double r3148455 = expm1(r3148454);
        double r3148456 = r3148453 / r3148455;
        double r3148457 = r3148456 * r3148451;
        return r3148457;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 40.4

    \[\frac{e^{x}}{e^{x} - 1}\]
  2. Using strategy rm
  3. Applied flip--40.4

    \[\leadsto \frac{e^{x}}{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}\]
  4. Applied associate-/r/40.4

    \[\leadsto \color{blue}{\frac{e^{x}}{e^{x} \cdot e^{x} - 1 \cdot 1} \cdot \left(e^{x} + 1\right)}\]
  5. Simplified0.4

    \[\leadsto \color{blue}{\frac{e^{x}}{\mathsf{expm1}\left(\left(x + x\right)\right)}} \cdot \left(e^{x} + 1\right)\]
  6. Using strategy rm
  7. Applied div-inv0.4

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

    \[\leadsto \color{blue}{e^{x} \cdot \left(\frac{1}{\mathsf{expm1}\left(\left(x + x\right)\right)} \cdot \left(e^{x} + 1\right)\right)}\]
  9. Simplified0.4

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

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

Reproduce

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

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

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