Average Error: 41.4 → 0.6
Time: 2.7s
Precision: binary64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;e^{x} \leq 0.6026705682579042:\\ \;\;\;\;\sqrt{e^{x}} \cdot \frac{\sqrt{e^{x}}}{e^{x} - 1}\\ \mathbf{else}:\\ \;\;\;\;0.5 + \left(x \cdot 0.08333333333333333 + \frac{1}{x}\right)\\ \end{array}\]
\frac{e^{x}}{e^{x} - 1}
\begin{array}{l}
\mathbf{if}\;e^{x} \leq 0.6026705682579042:\\
\;\;\;\;\sqrt{e^{x}} \cdot \frac{\sqrt{e^{x}}}{e^{x} - 1}\\

\mathbf{else}:\\
\;\;\;\;0.5 + \left(x \cdot 0.08333333333333333 + \frac{1}{x}\right)\\

\end{array}
double code(double x) {
	return (((double) exp(x)) / ((double) (((double) exp(x)) - 1.0)));
}
double code(double x) {
	double VAR;
	if ((((double) exp(x)) <= 0.6026705682579042)) {
		VAR = ((double) (((double) sqrt(((double) exp(x)))) * (((double) sqrt(((double) exp(x)))) / ((double) (((double) exp(x)) - 1.0)))));
	} else {
		VAR = ((double) (0.5 + ((double) (((double) (x * 0.08333333333333333)) + (1.0 / x)))));
	}
	return VAR;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (exp x) < 0.602670568257904216

    1. Initial program Error: 0.0 bits

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Using strategy rm
    3. Applied *-un-lft-identityError: 0.0 bits

      \[\leadsto \frac{e^{x}}{\color{blue}{1 \cdot \left(e^{x} - 1\right)}}\]
    4. Applied add-sqr-sqrtError: 0.0 bits

      \[\leadsto \frac{\color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}}{1 \cdot \left(e^{x} - 1\right)}\]
    5. Applied times-fracError: 0.0 bits

      \[\leadsto \color{blue}{\frac{\sqrt{e^{x}}}{1} \cdot \frac{\sqrt{e^{x}}}{e^{x} - 1}}\]
    6. SimplifiedError: 0.0 bits

      \[\leadsto \color{blue}{\sqrt{e^{x}}} \cdot \frac{\sqrt{e^{x}}}{e^{x} - 1}\]

    if 0.602670568257904216 < (exp x)

    1. Initial program Error: 61.6 bits

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Taylor expanded around 0 Error: 0.9 bits

      \[\leadsto \color{blue}{0.5 + \left(0.08333333333333333 \cdot x + \frac{1}{x}\right)}\]
    3. SimplifiedError: 0.9 bits

      \[\leadsto \color{blue}{0.5 + \left(x \cdot 0.08333333333333333 + \frac{1}{x}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplificationError: 0.6 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{x} \leq 0.6026705682579042:\\ \;\;\;\;\sqrt{e^{x}} \cdot \frac{\sqrt{e^{x}}}{e^{x} - 1}\\ \mathbf{else}:\\ \;\;\;\;0.5 + \left(x \cdot 0.08333333333333333 + \frac{1}{x}\right)\\ \end{array}\]

Reproduce

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

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

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