Average Error: 40.1 → 0.6
Time: 29.1s
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0015816628562246788:\\ \;\;\;\;\left(e^{x} + 1\right) \cdot \frac{e^{x}}{e^{x} \cdot e^{x} - 1}\\ \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.0015816628562246788:\\
\;\;\;\;\left(e^{x} + 1\right) \cdot \frac{e^{x}}{e^{x} \cdot e^{x} - 1}\\

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

\end{array}
double f(double x) {
        double r7159303 = x;
        double r7159304 = exp(r7159303);
        double r7159305 = 1.0;
        double r7159306 = r7159304 - r7159305;
        double r7159307 = r7159304 / r7159306;
        return r7159307;
}

double f(double x) {
        double r7159308 = x;
        double r7159309 = -0.0015816628562246788;
        bool r7159310 = r7159308 <= r7159309;
        double r7159311 = exp(r7159308);
        double r7159312 = 1.0;
        double r7159313 = r7159311 + r7159312;
        double r7159314 = r7159311 * r7159311;
        double r7159315 = r7159314 - r7159312;
        double r7159316 = r7159311 / r7159315;
        double r7159317 = r7159313 * r7159316;
        double r7159318 = r7159312 / r7159308;
        double r7159319 = 0.5;
        double r7159320 = r7159318 + r7159319;
        double r7159321 = 0.08333333333333333;
        double r7159322 = r7159321 * r7159308;
        double r7159323 = r7159320 + r7159322;
        double r7159324 = r7159310 ? r7159317 : r7159323;
        return r7159324;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.1
Target39.7
Herbie0.6
\[\frac{1}{1 - e^{-x}}\]

Derivation

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

    1. Initial program 0.0

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

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

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

    if -0.0015816628562246788 < x

    1. Initial program 60.2

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

      \[\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.6

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

Reproduce

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

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

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