Average Error: 39.4 → 0.4
Time: 7.2s
Precision: 64
$\frac{e^{x} - 1}{x}$
$\begin{array}{l} \mathbf{if}\;x \le -1.446298005470316198547986452638269838644 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{e^{x + x} - 1 \cdot 1}{e^{x} + 1}}{x}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{1}{6} \cdot x + \frac{1}{2}\right) + 1\\ \end{array}$
\frac{e^{x} - 1}{x}
\begin{array}{l}
\mathbf{if}\;x \le -1.446298005470316198547986452638269838644 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{e^{x + x} - 1 \cdot 1}{e^{x} + 1}}{x}\\

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

\end{array}
double f(double x) {
double r106630 = x;
double r106631 = exp(r106630);
double r106632 = 1.0;
double r106633 = r106631 - r106632;
double r106634 = r106633 / r106630;
return r106634;
}

double f(double x) {
double r106635 = x;
double r106636 = -0.00014462980054703162;
bool r106637 = r106635 <= r106636;
double r106638 = r106635 + r106635;
double r106639 = exp(r106638);
double r106640 = 1.0;
double r106641 = r106640 * r106640;
double r106642 = r106639 - r106641;
double r106643 = exp(r106635);
double r106644 = r106643 + r106640;
double r106645 = r106642 / r106644;
double r106646 = r106645 / r106635;
double r106647 = 0.16666666666666666;
double r106648 = r106647 * r106635;
double r106649 = 0.5;
double r106650 = r106648 + r106649;
double r106651 = r106635 * r106650;
double r106652 = 1.0;
double r106653 = r106651 + r106652;
double r106654 = r106637 ? r106646 : r106653;
return r106654;
}

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if x < -0.00014462980054703162

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.0

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

## if -0.00014462980054703162 < x

1. Initial program 59.8

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

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

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

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

# Reproduce

herbie shell --seed 1
(FPCore (x)
:name "(exp(x) - 1)/x"
:precision binary64
(/ (- (exp x) 1) x))