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

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

\end{array}
double f(double x) {
        double r3717877 = x;
        double r3717878 = exp(r3717877);
        double r3717879 = 1.0;
        double r3717880 = r3717878 - r3717879;
        double r3717881 = r3717880 / r3717877;
        return r3717881;
}

double f(double x) {
        double r3717882 = x;
        double r3717883 = -9.8136436745457e-05;
        bool r3717884 = r3717882 <= r3717883;
        double r3717885 = -1.0;
        double r3717886 = 3.0;
        double r3717887 = r3717886 * r3717882;
        double r3717888 = exp(r3717887);
        double r3717889 = r3717885 + r3717888;
        double r3717890 = exp(r3717882);
        double r3717891 = 1.0;
        double r3717892 = r3717890 + r3717891;
        double r3717893 = r3717890 * r3717892;
        double r3717894 = r3717893 + r3717891;
        double r3717895 = r3717889 / r3717894;
        double r3717896 = r3717895 / r3717882;
        double r3717897 = 0.16666666666666666;
        double r3717898 = r3717882 * r3717897;
        double r3717899 = 0.5;
        double r3717900 = r3717898 + r3717899;
        double r3717901 = r3717882 * r3717900;
        double r3717902 = r3717901 + r3717891;
        double r3717903 = r3717884 ? r3717896 : r3717902;
        return r3717903;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.6
Target39.7
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 < -9.8136436745457e-05

    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{\color{blue}{-1 + e^{3 \cdot x}}}{e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)}}{x}\]
    5. Simplified0.1

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

    if -9.8136436745457e-05 < x

    1. Initial program 60.1

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

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

      \[\leadsto \color{blue}{1 + x \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 -9.8136436745457 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{-1 + e^{3 \cdot x}}{e^{x} \cdot \left(e^{x} + 1\right) + 1}}{x}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{1}{6} + \frac{1}{2}\right) + 1\\ \end{array}\]

Reproduce

herbie shell --seed 2019158 
(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))