Average Error: 41.4 → 0.4
Time: 3.2s
Precision: binary64
\[\frac{e^{x}}{e^{x} - 1} \]
\[\frac{1}{\mathsf{expm1}\left(x\right)} \cdot e^{x} \]
\frac{e^{x}}{e^{x} - 1}
\frac{1}{\mathsf{expm1}\left(x\right)} \cdot e^{x}
(FPCore (x) :precision binary64 (/ (exp x) (- (exp x) 1.0)))
(FPCore (x) :precision binary64 (* (/ 1.0 (expm1 x)) (exp x)))
double code(double x) {
	return exp(x) / (exp(x) - 1.0);
}
double code(double x) {
	return (1.0 / expm1(x)) * exp(x);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original41.4
Target41.0
Herbie0.4
\[\frac{1}{1 - e^{-x}} \]

Derivation

  1. Initial program 41.4

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

    \[\leadsto \color{blue}{\frac{e^{x}}{\mathsf{expm1}\left(x\right)}} \]
  3. Applied add-sqr-sqrt_binary640.4

    \[\leadsto \frac{\color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}}{\mathsf{expm1}\left(x\right)} \]
  4. Applied associate-/l*_binary640.4

    \[\leadsto \color{blue}{\frac{\sqrt{e^{x}}}{\frac{\mathsf{expm1}\left(x\right)}{\sqrt{e^{x}}}}} \]
  5. Applied div-inv_binary640.4

    \[\leadsto \frac{\sqrt{e^{x}}}{\color{blue}{\mathsf{expm1}\left(x\right) \cdot \frac{1}{\sqrt{e^{x}}}}} \]
  6. Applied *-un-lft-identity_binary640.4

    \[\leadsto \frac{\sqrt{\color{blue}{1 \cdot e^{x}}}}{\mathsf{expm1}\left(x\right) \cdot \frac{1}{\sqrt{e^{x}}}} \]
  7. Applied sqrt-prod_binary640.4

    \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{e^{x}}}}{\mathsf{expm1}\left(x\right) \cdot \frac{1}{\sqrt{e^{x}}}} \]
  8. Applied times-frac_binary640.4

    \[\leadsto \color{blue}{\frac{\sqrt{1}}{\mathsf{expm1}\left(x\right)} \cdot \frac{\sqrt{e^{x}}}{\frac{1}{\sqrt{e^{x}}}}} \]
  9. Simplified0.4

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

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

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

Reproduce

herbie shell --seed 2022081 
(FPCore (x)
  :name "expq2 (section 3.11)"
  :precision binary64

  :herbie-target
  (/ 1.0 (- 1.0 (exp (- x))))

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