Average Error: 40.0 → 0.3
Time: 8.1s
Precision: 64
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.49858408664406162 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{e^{x + x} - 1 \cdot 1}{e^{x} + 1}}{x}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{x + {x}^{2} \cdot \left(x \cdot \frac{1}{6} + \frac{1}{2}\right)}{x}} \cdot \left(1 + x \cdot \left(\frac{1}{4} + x \cdot \frac{5}{96}\right)\right)\\ \end{array}\]
\frac{e^{x} - 1}{x}
\begin{array}{l}
\mathbf{if}\;x \le -1.49858408664406162 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{e^{x + x} - 1 \cdot 1}{e^{x} + 1}}{x}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{x + {x}^{2} \cdot \left(x \cdot \frac{1}{6} + \frac{1}{2}\right)}{x}} \cdot \left(1 + x \cdot \left(\frac{1}{4} + x \cdot \frac{5}{96}\right)\right)\\

\end{array}
double f(double x) {
        double r80135 = x;
        double r80136 = exp(r80135);
        double r80137 = 1.0;
        double r80138 = r80136 - r80137;
        double r80139 = r80138 / r80135;
        return r80139;
}

double f(double x) {
        double r80140 = x;
        double r80141 = -0.00014985840866440616;
        bool r80142 = r80140 <= r80141;
        double r80143 = r80140 + r80140;
        double r80144 = exp(r80143);
        double r80145 = 1.0;
        double r80146 = r80145 * r80145;
        double r80147 = r80144 - r80146;
        double r80148 = exp(r80140);
        double r80149 = r80148 + r80145;
        double r80150 = r80147 / r80149;
        double r80151 = r80150 / r80140;
        double r80152 = 2.0;
        double r80153 = pow(r80140, r80152);
        double r80154 = 0.16666666666666666;
        double r80155 = r80140 * r80154;
        double r80156 = 0.5;
        double r80157 = r80155 + r80156;
        double r80158 = r80153 * r80157;
        double r80159 = r80140 + r80158;
        double r80160 = r80159 / r80140;
        double r80161 = sqrt(r80160);
        double r80162 = 1.0;
        double r80163 = 0.25;
        double r80164 = 0.052083333333333336;
        double r80165 = r80140 * r80164;
        double r80166 = r80163 + r80165;
        double r80167 = r80140 * r80166;
        double r80168 = r80162 + r80167;
        double r80169 = r80161 * r80168;
        double r80170 = r80142 ? r80151 : r80169;
        return r80170;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.0
Target40.5
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.00014985840866440616

    1. Initial program 0.1

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

      \[\leadsto \frac{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}{x}\]
    4. Simplified0.1

      \[\leadsto \frac{\frac{\color{blue}{e^{x + x} - 1 \cdot 1}}{e^{x} + 1}}{x}\]

    if -0.00014985840866440616 < 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. Simplified0.5

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

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

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

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

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

Reproduce

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