Average Error: 40.0 → 0.3
Time: 8.7s
Precision: 64
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.001295637312997516450707724544599841465242:\\ \;\;\;\;\frac{\log \left(e^{e^{x} - 1}\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\frac{1}{12} \cdot {x}^{2} + 1\right) - \frac{1}{2} \cdot x}\\ \end{array}\]
\frac{e^{x} - 1}{x}
\begin{array}{l}
\mathbf{if}\;x \le -0.001295637312997516450707724544599841465242:\\
\;\;\;\;\frac{\log \left(e^{e^{x} - 1}\right)}{x}\\

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

\end{array}
double f(double x) {
        double r61289 = x;
        double r61290 = exp(r61289);
        double r61291 = 1.0;
        double r61292 = r61290 - r61291;
        double r61293 = r61292 / r61289;
        return r61293;
}

double f(double x) {
        double r61294 = x;
        double r61295 = -0.0012956373129975165;
        bool r61296 = r61294 <= r61295;
        double r61297 = exp(r61294);
        double r61298 = 1.0;
        double r61299 = r61297 - r61298;
        double r61300 = exp(r61299);
        double r61301 = log(r61300);
        double r61302 = r61301 / r61294;
        double r61303 = 1.0;
        double r61304 = 0.08333333333333333;
        double r61305 = 2.0;
        double r61306 = pow(r61294, r61305);
        double r61307 = r61304 * r61306;
        double r61308 = r61307 + r61303;
        double r61309 = 0.5;
        double r61310 = r61309 * r61294;
        double r61311 = r61308 - r61310;
        double r61312 = r61303 / r61311;
        double r61313 = r61296 ? r61302 : r61312;
        return r61313;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.0
Target40.4
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.0012956373129975165

    1. Initial program 0.0

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

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

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

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

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

    if -0.0012956373129975165 < x

    1. Initial program 60.0

      \[\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. Using strategy rm
    4. Applied clear-num0.5

      \[\leadsto \color{blue}{\frac{1}{\frac{x}{\frac{1}{2} \cdot {x}^{2} + \left(\frac{1}{6} \cdot {x}^{3} + x\right)}}}\]
    5. Taylor expanded around 0 0.4

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

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

Reproduce

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