Average Error: 39.5 → 0.4
Time: 25.8s
Precision: 64
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.00010099176561525294:\\ \;\;\;\;\log \left(e^{\frac{e^{\left(x + x\right) + x} + -1}{1 + e^{x} \cdot \left(e^{x} + 1\right)}}\right) \cdot \frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\frac{1}{2} + x \cdot \frac{1}{6}\right) \cdot x\\ \end{array}\]
\frac{e^{x} - 1}{x}
\begin{array}{l}
\mathbf{if}\;x \le -0.00010099176561525294:\\
\;\;\;\;\log \left(e^{\frac{e^{\left(x + x\right) + x} + -1}{1 + e^{x} \cdot \left(e^{x} + 1\right)}}\right) \cdot \frac{1}{x}\\

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

\end{array}
double f(double x) {
        double r10230170 = x;
        double r10230171 = exp(r10230170);
        double r10230172 = 1.0;
        double r10230173 = r10230171 - r10230172;
        double r10230174 = r10230173 / r10230170;
        return r10230174;
}

double f(double x) {
        double r10230175 = x;
        double r10230176 = -0.00010099176561525294;
        bool r10230177 = r10230175 <= r10230176;
        double r10230178 = r10230175 + r10230175;
        double r10230179 = r10230178 + r10230175;
        double r10230180 = exp(r10230179);
        double r10230181 = -1.0;
        double r10230182 = r10230180 + r10230181;
        double r10230183 = 1.0;
        double r10230184 = exp(r10230175);
        double r10230185 = r10230184 + r10230183;
        double r10230186 = r10230184 * r10230185;
        double r10230187 = r10230183 + r10230186;
        double r10230188 = r10230182 / r10230187;
        double r10230189 = exp(r10230188);
        double r10230190 = log(r10230189);
        double r10230191 = r10230183 / r10230175;
        double r10230192 = r10230190 * r10230191;
        double r10230193 = 0.5;
        double r10230194 = 0.16666666666666666;
        double r10230195 = r10230175 * r10230194;
        double r10230196 = r10230193 + r10230195;
        double r10230197 = r10230196 * r10230175;
        double r10230198 = r10230183 + r10230197;
        double r10230199 = r10230177 ? r10230192 : r10230198;
        return r10230199;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.5
Target38.7
Herbie0.4
\[\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.00010099176561525294

    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. Applied associate-/l/0.1

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

      \[\leadsto \frac{\color{blue}{e^{x + \left(x + x\right)} + -1}}{x \cdot \left(e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity0.1

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

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

      \[\leadsto \frac{1}{x} \cdot \color{blue}{\frac{e^{\left(x + x\right) + x} + -1}{e^{x} \cdot \left(e^{x} + 1\right) + 1}}\]
    10. Using strategy rm
    11. Applied add-log-exp0.1

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

    if -0.00010099176561525294 < x

    1. Initial program 60.0

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

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

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

Reproduce

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