Average Error: 41.5 → 0.9
Time: 4.2s
Precision: binary64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\frac{e^{x}}{x + \left(x \cdot x\right) \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)}\]
\frac{e^{x}}{e^{x} - 1}
\frac{e^{x}}{x + \left(x \cdot x\right) \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)}
(FPCore (x) :precision binary64 (/ (exp x) (- (exp x) 1.0)))
(FPCore (x)
 :precision binary64
 (/
  (exp x)
  (+
   x
   (*
    (* x x)
    (+ 0.5 (* x (+ 0.16666666666666666 (* x 0.041666666666666664))))))))
double code(double x) {
	return exp(x) / (exp(x) - 1.0);
}
double code(double x) {
	return exp(x) / (x + ((x * x) * (0.5 + (x * (0.16666666666666666 + (x * 0.041666666666666664))))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original41.5
Target41.1
Herbie0.9
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Initial program 41.5

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

    \[\leadsto \frac{e^{x}}{\color{blue}{x + \left(0.5 \cdot {x}^{2} + \left(0.16666666666666666 \cdot {x}^{3} + 0.041666666666666664 \cdot {x}^{4}\right)\right)}}\]
  3. Simplified0.9

    \[\leadsto \frac{e^{x}}{\color{blue}{x + \left(x \cdot x\right) \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)}}\]
  4. Final simplification0.9

    \[\leadsto \frac{e^{x}}{x + \left(x \cdot x\right) \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)}\]

Reproduce

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

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

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