Average Error: 41.2 → 1.0
Time: 2.3s
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \frac{1}{6}, \frac{1}{2}\right), {x}^{2}, x\right)}{e^{x}}}\]
\frac{e^{x}}{e^{x} - 1}
\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \frac{1}{6}, \frac{1}{2}\right), {x}^{2}, x\right)}{e^{x}}}
double code(double x) {
	return (exp(x) / (exp(x) - 1.0));
}
double code(double x) {
	return (1.0 / (fma(fma(x, 0.16666666666666666, 0.5), pow(x, 2.0), x) / exp(x)));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original41.2
Target40.7
Herbie1.0
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Initial program 41.2

    \[\frac{e^{x}}{e^{x} - 1}\]
  2. Taylor expanded around 0 11.8

    \[\leadsto \frac{e^{x}}{\color{blue}{\frac{1}{2} \cdot {x}^{2} + \left(\frac{1}{6} \cdot {x}^{3} + x\right)}}\]
  3. Simplified1.0

    \[\leadsto \frac{e^{x}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, \frac{1}{6}, \frac{1}{2}\right), {x}^{2}, x\right)}}\]
  4. Using strategy rm
  5. Applied clear-num1.0

    \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \frac{1}{6}, \frac{1}{2}\right), {x}^{2}, x\right)}{e^{x}}}}\]
  6. Final simplification1.0

    \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \frac{1}{6}, \frac{1}{2}\right), {x}^{2}, x\right)}{e^{x}}}\]

Reproduce

herbie shell --seed 2020078 +o rules:numerics
(FPCore (x)
  :name "expq2 (section 3.11)"
  :precision binary64

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

  (/ (exp x) (- (exp x) 1)))