Average Error: 39.4 → 0.0
Time: 10.8s
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 r2483052 = x;
        double r2483053 = exp(r2483052);
        double r2483054 = 1.0;
        double r2483055 = r2483053 - r2483054;
        double r2483056 = r2483055 / r2483052;
        return r2483056;
}

double f(double x) {
        double r2483057 = 1.0;
        double r2483058 = x;
        double r2483059 = expm1(r2483058);
        double r2483060 = r2483058 / r2483059;
        double r2483061 = r2483057 / r2483060;
        return r2483061;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.4
Target38.6
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.4

    \[\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 2019163 +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))