Average Error: 39.4 → 0.3
Time: 11.5s
Precision: 64
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.000188050340254322:\\ \;\;\;\;\frac{\left(\sqrt[3]{\log \left(e^{-1 + e^{x}}\right)} \cdot \sqrt[3]{\log \left(e^{-1 + e^{x}}\right)}\right) \cdot \sqrt[3]{\log \left(e^{-1 + e^{x}}\right)}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot x\right) \cdot \left(\frac{1}{6} \cdot x + \frac{1}{2}\right) + x}{x}\\ \end{array}\]
\frac{e^{x} - 1}{x}
\begin{array}{l}
\mathbf{if}\;x \le -0.000188050340254322:\\
\;\;\;\;\frac{\left(\sqrt[3]{\log \left(e^{-1 + e^{x}}\right)} \cdot \sqrt[3]{\log \left(e^{-1 + e^{x}}\right)}\right) \cdot \sqrt[3]{\log \left(e^{-1 + e^{x}}\right)}}{x}\\

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

\end{array}
double f(double x) {
        double r1369078 = x;
        double r1369079 = exp(r1369078);
        double r1369080 = 1.0;
        double r1369081 = r1369079 - r1369080;
        double r1369082 = r1369081 / r1369078;
        return r1369082;
}

double f(double x) {
        double r1369083 = x;
        double r1369084 = -0.000188050340254322;
        bool r1369085 = r1369083 <= r1369084;
        double r1369086 = -1.0;
        double r1369087 = exp(r1369083);
        double r1369088 = r1369086 + r1369087;
        double r1369089 = exp(r1369088);
        double r1369090 = log(r1369089);
        double r1369091 = cbrt(r1369090);
        double r1369092 = r1369091 * r1369091;
        double r1369093 = r1369092 * r1369091;
        double r1369094 = r1369093 / r1369083;
        double r1369095 = r1369083 * r1369083;
        double r1369096 = 0.16666666666666666;
        double r1369097 = r1369096 * r1369083;
        double r1369098 = 0.5;
        double r1369099 = r1369097 + r1369098;
        double r1369100 = r1369095 * r1369099;
        double r1369101 = r1369100 + r1369083;
        double r1369102 = r1369101 / r1369083;
        double r1369103 = r1369085 ? r1369094 : r1369102;
        return r1369103;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.4
Target38.6
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;x \lt 1 \land x \gt -1:\\ \;\;\;\;\frac{e^{x} - 1}{\log \left(e^{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x} - 1}{x}\\ \end{array}\]

Derivation

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

    1. Initial program 0.1

      \[\frac{e^{x} - 1}{x}\]
    2. Using strategy rm
    3. Applied add-log-exp0.1

      \[\leadsto \frac{e^{x} - \color{blue}{\log \left(e^{1}\right)}}{x}\]
    4. Applied add-log-exp0.1

      \[\leadsto \frac{\color{blue}{\log \left(e^{e^{x}}\right)} - \log \left(e^{1}\right)}{x}\]
    5. Applied diff-log0.1

      \[\leadsto \frac{\color{blue}{\log \left(\frac{e^{e^{x}}}{e^{1}}\right)}}{x}\]
    6. Simplified0.1

      \[\leadsto \frac{\log \color{blue}{\left(e^{-1 + e^{x}}\right)}}{x}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt0.1

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

    if -0.000188050340254322 < x

    1. Initial program 60.2

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

      \[\leadsto \frac{\color{blue}{x + \left(\frac{1}{6} \cdot {x}^{3} + \frac{1}{2} \cdot {x}^{2}\right)}}{x}\]
    3. Simplified0.4

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

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

Reproduce

herbie shell --seed 2019152 
(FPCore (x)
  :name "Kahan's exp quotient"

  :herbie-target
  (if (and (< x 1) (> x -1)) (/ (- (exp x) 1) (log (exp x))) (/ (- (exp x) 1) x))

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