Average Error: 39.4 → 0.0
Time: 6.8s
Precision: 64
\[\frac{e^{x} - 1}{x}\]
\[\frac{\frac{1}{x}}{\frac{1}{\mathsf{expm1}\left(x\right)}}\]
\frac{e^{x} - 1}{x}
\frac{\frac{1}{x}}{\frac{1}{\mathsf{expm1}\left(x\right)}}
double f(double x) {
        double r1093963 = x;
        double r1093964 = exp(r1093963);
        double r1093965 = 1.0;
        double r1093966 = r1093964 - r1093965;
        double r1093967 = r1093966 / r1093963;
        return r1093967;
}

double f(double x) {
        double r1093968 = 1.0;
        double r1093969 = x;
        double r1093970 = r1093968 / r1093969;
        double r1093971 = expm1(r1093969);
        double r1093972 = r1093968 / r1093971;
        double r1093973 = r1093970 / r1093972;
        return r1093973;
}

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. Using strategy rm
  6. Applied div-inv0.1

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

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

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

Reproduce

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