Average Error: 40.0 → 0.0
Time: 10.1s
Precision: 64
\[\frac{e^{x} - 1}{x}\]
\[(e^{\log_* (1 + \frac{(e^{x} - 1)^*}{x})} - 1)^*\]
double f(double x) {
        double r3675509 = x;
        double r3675510 = exp(r3675509);
        double r3675511 = 1.0;
        double r3675512 = r3675510 - r3675511;
        double r3675513 = r3675512 / r3675509;
        return r3675513;
}

double f(double x) {
        double r3675514 = x;
        double r3675515 = expm1(r3675514);
        double r3675516 = r3675515 / r3675514;
        double r3675517 = log1p(r3675516);
        double r3675518 = expm1(r3675517);
        return r3675518;
}

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

Error

Bits error versus x

Target

Original40.0
Target39.2
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;x \lt 1 \land x \gt -1:\\ \;\;\;\;\frac{e^{x} - 1}{\log \left(e^{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x} - 1}{x}\\ \end{array}\]

Derivation

  1. Initial program 40.0

    \[\frac{e^{x} - 1}{x}\]
  2. Simplified0.0

    \[\leadsto \color{blue}{\frac{(e^{x} - 1)^*}{x}}\]
  3. Using strategy rm
  4. Applied expm1-log1p-u0.0

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

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

Reproduce

herbie shell --seed 2019102 +o rules:numerics
(FPCore (x)
  :name "Kahan's exp quotient"

  :herbie-target
  (if (and (< x 1) (> x -1)) (/ (- (exp x) 1) (log (exp x))) (/ (- (exp x) 1) x))

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