Average Error: 40.3 → 0.3
Time: 12.7s
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\frac{e^{x}}{(e^{x} - 1)^*}\]
double f(double x) {
        double r6257911 = x;
        double r6257912 = exp(r6257911);
        double r6257913 = 1.0;
        double r6257914 = r6257912 - r6257913;
        double r6257915 = r6257912 / r6257914;
        return r6257915;
}

double f(double x) {
        double r6257916 = x;
        double r6257917 = exp(r6257916);
        double r6257918 = expm1(r6257916);
        double r6257919 = r6257917 / r6257918;
        return r6257919;
}

\frac{e^{x}}{e^{x} - 1}
\frac{e^{x}}{(e^{x} - 1)^*}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 40.3

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

    \[\leadsto \frac{e^{x}}{\color{blue}{(e^{x} - 1)^*}}\]
  4. Final simplification0.3

    \[\leadsto \frac{e^{x}}{(e^{x} - 1)^*}\]

Reproduce

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

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

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