Average Error: 39.4 → 0.0
Time: 1.8s
Precision: binary64
\[\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)}}
(FPCore (x) :precision binary64 (/ (- (exp x) 1.0) x))
(FPCore (x) :precision binary64 (/ 1.0 (/ x (expm1 x))))
double code(double x) {
	return (exp(x) - 1.0) / x;
}
double code(double x) {
	return 1.0 / (x / expm1(x));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.4
Target39.7
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;x < 1 \land x > -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 expm1-udef_binary6439.4

    \[\leadsto \frac{\color{blue}{e^{x} - 1}}{x} \]
  5. Applied div-sub_binary6439.1

    \[\leadsto \color{blue}{\frac{e^{x}}{x} - \frac{1}{x}} \]
  6. Applied frac-sub_binary6450.0

    \[\leadsto \color{blue}{\frac{e^{x} \cdot x - x \cdot 1}{x \cdot x}} \]
  7. Simplified30.2

    \[\leadsto \frac{\color{blue}{x \cdot \mathsf{expm1}\left(x\right)}}{x \cdot x} \]
  8. Using strategy rm
  9. Applied clear-num_binary6430.2

    \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x}{x \cdot \mathsf{expm1}\left(x\right)}}} \]
  10. Simplified0.0

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

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

Reproduce

herbie shell --seed 2021211 
(FPCore (x)
  :name "Kahan's exp quotient"
  :precision binary64

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

  (/ (- (exp x) 1.0) x))