Average Error: 40.6 → 0.5
Time: 12.8s
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0013573601244548715:\\ \;\;\;\;\frac{e^{x}}{e^{x + \left(x + x\right)} - 1} \cdot \left(\sqrt[3]{e^{x + \left(x + x\right)} \cdot e^{x + \left(x + x\right)}} + \left(1 + e^{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{12} + \left(\frac{1}{x} + \frac{1}{2}\right)\\ \end{array}\]
\frac{e^{x}}{e^{x} - 1}
\begin{array}{l}
\mathbf{if}\;x \le -0.0013573601244548715:\\
\;\;\;\;\frac{e^{x}}{e^{x + \left(x + x\right)} - 1} \cdot \left(\sqrt[3]{e^{x + \left(x + x\right)} \cdot e^{x + \left(x + x\right)}} + \left(1 + e^{x}\right)\right)\\

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

\end{array}
double f(double x) {
        double r1404365 = x;
        double r1404366 = exp(r1404365);
        double r1404367 = 1.0;
        double r1404368 = r1404366 - r1404367;
        double r1404369 = r1404366 / r1404368;
        return r1404369;
}

double f(double x) {
        double r1404370 = x;
        double r1404371 = -0.0013573601244548715;
        bool r1404372 = r1404370 <= r1404371;
        double r1404373 = exp(r1404370);
        double r1404374 = r1404370 + r1404370;
        double r1404375 = r1404370 + r1404374;
        double r1404376 = exp(r1404375);
        double r1404377 = 1.0;
        double r1404378 = r1404376 - r1404377;
        double r1404379 = r1404373 / r1404378;
        double r1404380 = r1404376 * r1404376;
        double r1404381 = cbrt(r1404380);
        double r1404382 = r1404377 + r1404373;
        double r1404383 = r1404381 + r1404382;
        double r1404384 = r1404379 * r1404383;
        double r1404385 = 0.08333333333333333;
        double r1404386 = r1404370 * r1404385;
        double r1404387 = r1404377 / r1404370;
        double r1404388 = 0.5;
        double r1404389 = r1404387 + r1404388;
        double r1404390 = r1404386 + r1404389;
        double r1404391 = r1404372 ? r1404384 : r1404390;
        return r1404391;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.6
Target40.3
Herbie0.5
\[\frac{1}{1 - e^{-x}}\]

Derivation

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

    1. Initial program 0.0

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Using strategy rm
    3. Applied flip3--0.0

      \[\leadsto \frac{e^{x}}{\color{blue}{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)}}}\]
    4. Applied associate-/r/0.0

      \[\leadsto \color{blue}{\frac{e^{x}}{{\left(e^{x}\right)}^{3} - {1}^{3}} \cdot \left(e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)}\]
    5. Simplified0.0

      \[\leadsto \color{blue}{\frac{e^{x}}{e^{\left(x + x\right) + x} - 1}} \cdot \left(e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)\]
    6. Using strategy rm
    7. Applied add-cbrt-cube0.0

      \[\leadsto \frac{e^{x}}{e^{\left(x + x\right) + x} - 1} \cdot \left(e^{x} \cdot \color{blue}{\sqrt[3]{\left(e^{x} \cdot e^{x}\right) \cdot e^{x}}} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)\]
    8. Applied add-cbrt-cube0.0

      \[\leadsto \frac{e^{x}}{e^{\left(x + x\right) + x} - 1} \cdot \left(\color{blue}{\sqrt[3]{\left(e^{x} \cdot e^{x}\right) \cdot e^{x}}} \cdot \sqrt[3]{\left(e^{x} \cdot e^{x}\right) \cdot e^{x}} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)\]
    9. Applied cbrt-unprod0.0

      \[\leadsto \frac{e^{x}}{e^{\left(x + x\right) + x} - 1} \cdot \left(\color{blue}{\sqrt[3]{\left(\left(e^{x} \cdot e^{x}\right) \cdot e^{x}\right) \cdot \left(\left(e^{x} \cdot e^{x}\right) \cdot e^{x}\right)}} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)\]
    10. Simplified0.0

      \[\leadsto \frac{e^{x}}{e^{\left(x + x\right) + x} - 1} \cdot \left(\sqrt[3]{\color{blue}{e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x}}} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)\]

    if -0.0013573601244548715 < x

    1. Initial program 60.3

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

      \[\leadsto \color{blue}{\frac{1}{12} \cdot x + \left(\frac{1}{x} + \frac{1}{2}\right)}\]
    3. Using strategy rm
    4. Applied +-commutative0.7

      \[\leadsto \color{blue}{\left(\frac{1}{x} + \frac{1}{2}\right) + \frac{1}{12} \cdot x}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.0013573601244548715:\\ \;\;\;\;\frac{e^{x}}{e^{x + \left(x + x\right)} - 1} \cdot \left(\sqrt[3]{e^{x + \left(x + x\right)} \cdot e^{x + \left(x + x\right)}} + \left(1 + e^{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{12} + \left(\frac{1}{x} + \frac{1}{2}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019154 
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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