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

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

\end{array}
double f(double x) {
        double r5840660 = x;
        double r5840661 = exp(r5840660);
        double r5840662 = 1.0;
        double r5840663 = r5840661 - r5840662;
        double r5840664 = r5840661 / r5840663;
        return r5840664;
}

double f(double x) {
        double r5840665 = x;
        double r5840666 = -0.0014245372640456257;
        bool r5840667 = r5840665 <= r5840666;
        double r5840668 = exp(r5840665);
        double r5840669 = 3.0;
        double r5840670 = r5840669 * r5840665;
        double r5840671 = exp(r5840670);
        double r5840672 = 1.0;
        double r5840673 = r5840672 * r5840672;
        double r5840674 = r5840672 * r5840673;
        double r5840675 = r5840671 - r5840674;
        double r5840676 = r5840668 + r5840672;
        double r5840677 = r5840668 * r5840676;
        double r5840678 = r5840677 + r5840673;
        double r5840679 = r5840675 / r5840678;
        double r5840680 = r5840679 * r5840679;
        double r5840681 = r5840680 * r5840679;
        double r5840682 = cbrt(r5840681);
        double r5840683 = r5840668 / r5840682;
        double r5840684 = 0.5;
        double r5840685 = 1.0;
        double r5840686 = r5840685 / r5840665;
        double r5840687 = r5840684 + r5840686;
        double r5840688 = 0.08333333333333333;
        double r5840689 = r5840665 * r5840688;
        double r5840690 = r5840687 + r5840689;
        double r5840691 = r5840667 ? r5840683 : r5840690;
        return r5840691;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

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

    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} - \left(1 \cdot 1\right) \cdot 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} - \left(1 \cdot 1\right) \cdot 1}{\color{blue}{1 \cdot 1 + e^{x} \cdot \left(1 + e^{x}\right)}}}\]
    6. Using strategy rm
    7. Applied add-cbrt-cube0.0

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

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

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

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

    if -0.0014245372640456257 < x

    1. Initial program 61.9

      \[\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. Recombined 2 regimes into one program.
  4. Final simplification0.4

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

Reproduce

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

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

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