Average Error: 40.2 → 0.4
Time: 10.5s
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\frac{e^{x}}{(e^{x} - 1)^*}\]
double f(double x) {
        double r4552884 = x;
        double r4552885 = exp(r4552884);
        double r4552886 = 1.0;
        double r4552887 = r4552885 - r4552886;
        double r4552888 = r4552885 / r4552887;
        return r4552888;
}

double f(double x) {
        double r4552889 = x;
        double r4552890 = exp(r4552889);
        double r4552891 = expm1(r4552889);
        double r4552892 = r4552890 / r4552891;
        return r4552892;
}

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

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 40.2

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

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

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

Reproduce

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

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

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