Average Error: 39.7 → 0.3
Time: 10.6s
Precision: 64
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.392605479495764375999500295222333079437 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{1 \cdot \left(e^{x} + 1\right) + e^{x + x}}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{x}{x + \left(x \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)}}\\ \end{array}\]
\frac{e^{x} - 1}{x}
\begin{array}{l}
\mathbf{if}\;x \le -1.392605479495764375999500295222333079437 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{1 \cdot \left(e^{x} + 1\right) + e^{x + x}}}{x}\\

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

\end{array}
double f(double x) {
        double r118751 = x;
        double r118752 = exp(r118751);
        double r118753 = 1.0;
        double r118754 = r118752 - r118753;
        double r118755 = r118754 / r118751;
        return r118755;
}

double f(double x) {
        double r118756 = x;
        double r118757 = -0.00013926054794957644;
        bool r118758 = r118756 <= r118757;
        double r118759 = exp(r118756);
        double r118760 = 3.0;
        double r118761 = pow(r118759, r118760);
        double r118762 = 1.0;
        double r118763 = pow(r118762, r118760);
        double r118764 = r118761 - r118763;
        double r118765 = r118759 + r118762;
        double r118766 = r118762 * r118765;
        double r118767 = r118756 + r118756;
        double r118768 = exp(r118767);
        double r118769 = r118766 + r118768;
        double r118770 = r118764 / r118769;
        double r118771 = r118770 / r118756;
        double r118772 = 1.0;
        double r118773 = r118756 * r118756;
        double r118774 = 0.5;
        double r118775 = 0.16666666666666666;
        double r118776 = r118775 * r118756;
        double r118777 = r118774 + r118776;
        double r118778 = r118773 * r118777;
        double r118779 = r118756 + r118778;
        double r118780 = r118756 / r118779;
        double r118781 = r118772 / r118780;
        double r118782 = r118758 ? r118771 : r118781;
        return r118782;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.7
Target40.0
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.00013926054794957644

    1. Initial program 0.1

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

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

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

    if -0.00013926054794957644 < x

    1. Initial program 59.9

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

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

      \[\leadsto \frac{\color{blue}{x + \left(x \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)}}{x}\]
    4. Using strategy rm
    5. Applied clear-num0.5

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

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

Reproduce

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

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

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