Average Error: 38.4 → 0.5
Time: 36.3s
Precision: 64
$\frac{\log \left(x + 1\right)}{e^{x - 1}}$
$\begin{array}{l} \mathbf{if}\;x \le 5.140320595227230989290607282571343716882 \cdot 10^{-6}:\\ \;\;\;\;\left(1 \cdot \frac{x}{e^{x - 1}} + \frac{\log 1}{e^{x - 1}}\right) - 0.5 \cdot \frac{{x}^{2}}{e^{x - 1}}\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{\frac{\log \left(x + 1\right)}{e^{x - 1}}}\right)\\ \end{array}$
\frac{\log \left(x + 1\right)}{e^{x - 1}}
\begin{array}{l}
\mathbf{if}\;x \le 5.140320595227230989290607282571343716882 \cdot 10^{-6}:\\
\;\;\;\;\left(1 \cdot \frac{x}{e^{x - 1}} + \frac{\log 1}{e^{x - 1}}\right) - 0.5 \cdot \frac{{x}^{2}}{e^{x - 1}}\\

\mathbf{else}:\\
\;\;\;\;\log \left(e^{\frac{\log \left(x + 1\right)}{e^{x - 1}}}\right)\\

\end{array}
double f(double x) {
double r1348230 = x;
double r1348231 = 1.0;
double r1348232 = r1348230 + r1348231;
double r1348233 = log(r1348232);
double r1348234 = r1348230 - r1348231;
double r1348235 = exp(r1348234);
double r1348236 = r1348233 / r1348235;
return r1348236;
}


double f(double x) {
double r1348237 = x;
double r1348238 = 5.140320595227231e-06;
bool r1348239 = r1348237 <= r1348238;
double r1348240 = 1.0;
double r1348241 = r1348237 - r1348240;
double r1348242 = exp(r1348241);
double r1348243 = r1348237 / r1348242;
double r1348244 = r1348240 * r1348243;
double r1348245 = log(r1348240);
double r1348246 = r1348245 / r1348242;
double r1348247 = r1348244 + r1348246;
double r1348248 = 0.5;
double r1348249 = 2.0;
double r1348250 = pow(r1348237, r1348249);
double r1348251 = r1348250 / r1348242;
double r1348252 = r1348248 * r1348251;
double r1348253 = r1348247 - r1348252;
double r1348254 = r1348237 + r1348240;
double r1348255 = log(r1348254);
double r1348256 = r1348255 / r1348242;
double r1348257 = exp(r1348256);
double r1348258 = log(r1348257);
double r1348259 = r1348239 ? r1348253 : r1348258;
return r1348259;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if x < 5.140320595227231e-06

1. Initial program 58.9

$\frac{\log \left(x + 1\right)}{e^{x - 1}}$
2. Taylor expanded around 0 0.6

$\leadsto \frac{\color{blue}{\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}}{e^{x - 1}}$
3. Taylor expanded around inf 0.6

$\leadsto \color{blue}{\left(1 \cdot \frac{x}{e^{x - 1}} + \frac{\log 1}{e^{x - 1}}\right) - 0.5 \cdot \frac{{x}^{2}}{e^{x - 1}}}$

## if 5.140320595227231e-06 < x

1. Initial program 0.2

$\frac{\log \left(x + 1\right)}{e^{x - 1}}$
2. Using strategy rm

$\leadsto \color{blue}{\log \left(e^{\frac{\log \left(x + 1\right)}{e^{x - 1}}}\right)}$
3. Recombined 2 regimes into one program.
4. Final simplification0.5

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

# Reproduce

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