Average Error: 38.3 → 0.4
Time: 7.0s
Precision: 64
$e^{-x} - 1$
$\begin{array}{l} \mathbf{if}\;-x \le -0.005176362185749711943005824110741741606034:\\ \;\;\;\;\log \left(e^{e^{-x} - 1}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{2} \cdot \left(\frac{1}{2} - \frac{1}{6} \cdot x\right) - x\\ \end{array}$
e^{-x} - 1
\begin{array}{l}
\mathbf{if}\;-x \le -0.005176362185749711943005824110741741606034:\\
\;\;\;\;\log \left(e^{e^{-x} - 1}\right)\\

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

\end{array}
double f(double x) {
double r552917 = x;
double r552918 = -r552917;
double r552919 = exp(r552918);
double r552920 = 1.0;
double r552921 = r552919 - r552920;
return r552921;
}


double f(double x) {
double r552922 = x;
double r552923 = -r552922;
double r552924 = -0.005176362185749712;
bool r552925 = r552923 <= r552924;
double r552926 = exp(r552923);
double r552927 = 1.0;
double r552928 = r552926 - r552927;
double r552929 = exp(r552928);
double r552930 = log(r552929);
double r552931 = 2.0;
double r552932 = pow(r552922, r552931);
double r552933 = 0.5;
double r552934 = 0.16666666666666666;
double r552935 = r552934 * r552922;
double r552936 = r552933 - r552935;
double r552937 = r552932 * r552936;
double r552938 = r552937 - r552922;
double r552939 = r552925 ? r552930 : r552938;
return r552939;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if (- x) < -0.005176362185749712

1. Initial program 0.0

$e^{-x} - 1$
2. Using strategy rm

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

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

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

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

## if -0.005176362185749712 < (- x)

1. Initial program 58.3

$e^{-x} - 1$
2. Taylor expanded around 0 0.6

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

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

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

# Reproduce

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