Average Error: 58.0 → 0.9
Time: 17.8s
Precision: 64
${e}^{x} - {e}^{\left(-x\right)}$
$\begin{array}{l} \mathbf{if}\;x \le 1.70973388373225840921051330587379646353 \cdot 10^{-8}:\\ \;\;\;\;2 \cdot \left(\log e \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;{e}^{x} - {e}^{\left(-x\right)}\\ \end{array}$
{e}^{x} - {e}^{\left(-x\right)}
\begin{array}{l}
\mathbf{if}\;x \le 1.70973388373225840921051330587379646353 \cdot 10^{-8}:\\
\;\;\;\;2 \cdot \left(\log e \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;{e}^{x} - {e}^{\left(-x\right)}\\

\end{array}
double f(double e, double x) {
double r17644815 = e;
double r17644816 = x;
double r17644817 = pow(r17644815, r17644816);
double r17644818 = -r17644816;
double r17644819 = pow(r17644815, r17644818);
double r17644820 = r17644817 - r17644819;
return r17644820;
}


double f(double e, double x) {
double r17644821 = x;
double r17644822 = 1.7097338837322584e-08;
bool r17644823 = r17644821 <= r17644822;
double r17644824 = 2.0;
double r17644825 = e;
double r17644826 = log(r17644825);
double r17644827 = r17644826 * r17644821;
double r17644828 = r17644824 * r17644827;
double r17644829 = pow(r17644825, r17644821);
double r17644830 = -r17644821;
double r17644831 = pow(r17644825, r17644830);
double r17644832 = r17644829 - r17644831;
double r17644833 = r17644823 ? r17644828 : r17644832;
return r17644833;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if x < 1.7097338837322584e-08

1. Initial program 58.8

${e}^{x} - {e}^{\left(-x\right)}$
2. Taylor expanded around 0 0.9

$\leadsto \color{blue}{2 \cdot \left(x \cdot \log e\right)}$

## if 1.7097338837322584e-08 < x

1. Initial program 4.8

${e}^{x} - {e}^{\left(-x\right)}$
3. Recombined 2 regimes into one program.
4. Final simplification0.9

$\leadsto \begin{array}{l} \mathbf{if}\;x \le 1.70973388373225840921051330587379646353 \cdot 10^{-8}:\\ \;\;\;\;2 \cdot \left(\log e \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;{e}^{x} - {e}^{\left(-x\right)}\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (e x)
:name "e^x-e^-x"
(- (pow e x) (pow e (- x))))