Average Error: 39.8 → 0.0
Time: 37.9s
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 r3395950 = x;
        double r3395951 = exp(r3395950);
        double r3395952 = 1.0;
        double r3395953 = r3395951 - r3395952;
        double r3395954 = r3395953 / r3395950;
        return r3395954;
}

double f(double x) {
        double r3395955 = 1.0;
        double r3395956 = x;
        double r3395957 = expm1(r3395956);
        double r3395958 = r3395956 / r3395957;
        double r3395959 = r3395955 / r3395958;
        return r3395959;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.8
Target39.0
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.8

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

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

    \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{expm1}\left(x\right)}}{x}\]
  5. Applied associate-/l*0.0

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

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

Reproduce

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