Average Error: 39.3 → 0.0
Time: 12.1s
Precision: 64
\[\frac{e^{x} - 1}{x}\]
\[\frac{1}{\frac{x}{\mathsf{expm1}\left(x\right)}}\]
\frac{e^{x} - 1}{x}
\frac{1}{\frac{x}{\mathsf{expm1}\left(x\right)}}
double f(double x) {
        double r2031470 = x;
        double r2031471 = exp(r2031470);
        double r2031472 = 1.0;
        double r2031473 = r2031471 - r2031472;
        double r2031474 = r2031473 / r2031470;
        return r2031474;
}

double f(double x) {
        double r2031475 = 1.0;
        double r2031476 = x;
        double r2031477 = expm1(r2031476);
        double r2031478 = r2031476 / r2031477;
        double r2031479 = r2031475 / r2031478;
        return r2031479;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.3
Target38.5
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 39.3

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

    \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(x\right)}{x}}\]
  3. Using strategy rm
  4. Applied clear-num0.0

    \[\leadsto \color{blue}{\frac{1}{\frac{x}{\mathsf{expm1}\left(x\right)}}}\]
  5. Final simplification0.0

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

Reproduce

herbie shell --seed 2019139 +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))