Average Error: 41.4 → 1.1
Time: 1.5min
Precision: binary64
Cost: 641
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -2.0163078676391955:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;0.5 + \frac{1}{x}\\ \end{array}\]
\frac{e^{x}}{e^{x} - 1}
\begin{array}{l}
\mathbf{if}\;x \leq -2.0163078676391955:\\
\;\;\;\;0\\

\mathbf{else}:\\
\;\;\;\;0.5 + \frac{1}{x}\\

\end{array}
(FPCore (x) :precision binary64 (/ (exp x) (- (exp x) 1.0)))
(FPCore (x)
 :precision binary64
 (if (<= x -2.0163078676391955) 0.0 (+ 0.5 (/ 1.0 x))))
double code(double x) {
	return exp(x) / (exp(x) - 1.0);
}
double code(double x) {
	double tmp;
	if (x <= -2.0163078676391955) {
		tmp = 0.0;
	} else {
		tmp = 0.5 + (1.0 / x);
	}
	return tmp;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original41.4
Target40.9
Herbie1.1
\[\frac{1}{1 - e^{-x}}\]

Alternatives

Alternative 1
Error1.0
Cost26560
\[\frac{\sqrt{e^{x}}}{1 + \sqrt{e^{x}}} \cdot \left(\left(0.5 + \frac{2}{x}\right) + x \cdot 0.041666666666666664\right)\]
Alternative 2
Error1.2
Cost26304
\[\frac{\sqrt{e^{x}}}{1 + \sqrt{e^{x}}} \cdot \left(0.5 + \frac{2}{x}\right)\]
Alternative 3
Error1.2
Cost7232
\[\frac{e^{x}}{x + \left(x \cdot x\right) \cdot \left(0.5 + x \cdot 0.0625\right)}\]
Alternative 4
Error1.2
Cost6976
\[\frac{e^{x}}{x + 0.5 \cdot \left(x \cdot x\right)}\]
Alternative 5
Error1.6
Cost6720
\[\frac{1}{x} \cdot e^{x}\]
Alternative 6
Error1.6
Cost6720
\[\frac{1}{\frac{x}{e^{x}}}\]
Alternative 7
Error1.6
Cost6592
\[\frac{e^{x}}{x}\]
Alternative 8
Error1.4
Cost641
\[\begin{array}{l} \mathbf{if}\;x \leq -1.014316485804236:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{1}{x}\\ \end{array}\]
Alternative 9
Error1.6
Cost513
\[\begin{array}{l} \mathbf{if}\;x \leq -354.84018584671594:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array}\]
Alternative 10
Error40.9
Cost385
\[\begin{array}{l} \mathbf{if}\;x \leq 5.60725183993995 \cdot 10^{-309}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]
Alternative 11
Error61.4
Cost64
\[1\]

Error

Time

Derivation

  1. Split input into 2 regimes
  2. if x < -2.0163078676391955

    1. Initial program 0.4

      \[0\]
    2. Simplified0.4

      \[\leadsto \color{blue}{0}\]

    if -2.0163078676391955 < x

    1. Initial program 61.6

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt_binary64_147761.7

      \[\leadsto \frac{e^{x}}{\color{blue}{\left(\sqrt[3]{e^{x} - 1} \cdot \sqrt[3]{e^{x} - 1}\right) \cdot \sqrt[3]{e^{x} - 1}}}\]
    4. Taylor expanded around 0 1.4

      \[\leadsto \color{blue}{\frac{1}{x} + 0.5}\]
    5. Simplified1.4

      \[\leadsto \color{blue}{0.5 + \frac{1}{x}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.0163078676391955:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;0.5 + \frac{1}{x}\\ \end{array}\]

Reproduce

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

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

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