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

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

\end{array}
double f(double x) {
        double r1969605 = x;
        double r1969606 = exp(r1969605);
        double r1969607 = 1.0;
        double r1969608 = r1969606 - r1969607;
        double r1969609 = r1969606 / r1969608;
        return r1969609;
}

double f(double x) {
        double r1969610 = x;
        double r1969611 = -0.0015135317601704878;
        bool r1969612 = r1969610 <= r1969611;
        double r1969613 = exp(r1969610);
        double r1969614 = 1.0;
        double r1969615 = r1969610 + r1969610;
        double r1969616 = r1969615 + r1969610;
        double r1969617 = exp(r1969616);
        double r1969618 = r1969617 + r1969614;
        double r1969619 = cbrt(r1969618);
        double r1969620 = r1969619 * r1969619;
        double r1969621 = r1969614 / r1969620;
        double r1969622 = r1969613 / r1969621;
        double r1969623 = r1969617 * r1969617;
        double r1969624 = r1969623 - r1969614;
        double r1969625 = r1969624 / r1969619;
        double r1969626 = r1969613 * r1969613;
        double r1969627 = r1969613 + r1969614;
        double r1969628 = r1969626 + r1969627;
        double r1969629 = r1969625 / r1969628;
        double r1969630 = r1969622 / r1969629;
        double r1969631 = r1969614 / r1969610;
        double r1969632 = 0.5;
        double r1969633 = r1969631 + r1969632;
        double r1969634 = 0.08333333333333333;
        double r1969635 = r1969634 * r1969610;
        double r1969636 = r1969633 + r1969635;
        double r1969637 = r1969612 ? r1969630 : r1969636;
        return r1969637;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

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

    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. Simplified0.0

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

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

      \[\leadsto \frac{e^{x}}{\frac{\color{blue}{\frac{e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x} - 1 \cdot 1}{e^{\left(x + x\right) + x} + 1}}}{\left(e^{x} + 1\right) + e^{x} \cdot e^{x}}}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity0.0

      \[\leadsto \frac{e^{x}}{\frac{\frac{e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x} - 1 \cdot 1}{e^{\left(x + x\right) + x} + 1}}{\color{blue}{1 \cdot \left(\left(e^{x} + 1\right) + e^{x} \cdot e^{x}\right)}}}\]
    10. Applied add-cube-cbrt0.0

      \[\leadsto \frac{e^{x}}{\frac{\frac{e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x} - 1 \cdot 1}{\color{blue}{\left(\sqrt[3]{e^{\left(x + x\right) + x} + 1} \cdot \sqrt[3]{e^{\left(x + x\right) + x} + 1}\right) \cdot \sqrt[3]{e^{\left(x + x\right) + x} + 1}}}}{1 \cdot \left(\left(e^{x} + 1\right) + e^{x} \cdot e^{x}\right)}}\]
    11. Applied *-un-lft-identity0.0

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

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

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

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

    if -0.0015135317601704878 < x

    1. Initial program 60.4

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

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

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

Reproduce

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

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

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