Solving $\int e^{|x|} dx$ Solving $\displaystyle\int e^{|x|} dx$.
I just solved a quite similar definite integral, and it wasn't hard, but it was because I could divide the integral in two integrals and get rid of modulus. Problem is I can't do that here, since it's indefinite now. I tried already substitution, parts, series and got nothing. How can I aproach such integral?
Thanks.
Edit: I'd like to obtain Wolfram's answer, not a function defined by parts.
 A: Let us express the antiderivative as a definite integral plus a constant.
$$\int e^{|x|}dx=\int_0^x e^{|x|}dx+C.$$
Then for positive $x$,
$$e^x-1+C$$
and for negative $x$,
$$1-e^{-x}+C.$$
Hence
$$\text{sgn}(x)\left(e^{|x|}-1\right)+C.$$

As we can check, the derivative is $\text{sgn}^2(x)e^{|x|}$ (and $1$ for $x=0$).

Note that WA seemed to strive to avoid the absolute value in the exponent. We can achieve the same effect with 
$$\text{sgn}(x)\frac{(1+\text{sgn}(x))(e^x-1)+(1-\text{sgn}(x))(e^{-x}-1)}{2}
=\frac{(\text{sgn}(x)+1)(e^x-1)-(\text{sgn}(x)-1)(e^x-1)e^{-x}}2
=e^{-x}\frac{\text{sgn}(x)(e^x-1)^2+e^{2x}-e^x-e^x-1}2.$$
This is ugly.
A: You should simply integrate separately for $x\ge 0$ and $x<0$. The result is then the function defined in different ways for $x\ge 0$ and $x<0$. 
(But it will be actually possible to write it as an unique expression).
A: The result given by Wolframalpha might seem attractive, but it isn't. Consider
$$
F(x)=\frac{1}{2}e^{-x}((e^x-1)^2\operatorname{sgn}(x)-2e^x+e^{2x}-1)
$$
(the integration constant is irrelevant); then, for $x>0$,
$$
F(x)=\frac{1}{2}e^{-x}(e^{2x}-2e^x+1-2e^x+e^{2x}-1)=
\frac{1}{2}e^{-x}(2e^{2x}-4e^x)=e^x-2
$$
For $x<0$,
$$
F(x)=\frac{1}{2}e^{-x}(-e^{2x}+2e^x-1-2e^x+e^{2x}-1)=-e^{-x}
$$
Also $F(0)=-1$ and it can be easily checked that $F'(x)=e^{|x|}$ for all $x$.
On the other hand, doing algebraic manipulations we obtain
$$
F(x)=\frac{1}{2}((e^x-2+e^{-x})\operatorname{sgn}(x)-2+e^x-e^{-x})
$$
Note that $e^x-e^{-x}=(e^{|x|}-e^{-|x|})\operatorname{sgn}(x)$ and that $e^x+e^{-x}=e^{|x|}+e^{-|x|}$, so we obtain
\begin{align}
F(x)
&=\frac{1}{2}((e^{|x|}+e^{-|x|}-2+e^{|x|}-e^{-|x|})\operatorname{sgn}(x)+2) \\[6px]
&=(e^{|x|}-1)\operatorname{sgn}(x)+1
\end{align}
which is much simpler, isn't it?
A: Write $e^{|x|}=e^{\operatorname{sgn}(x) x}$. Then
$$\int e^{|x|} dx = \int e^{\operatorname{sgn}(x)x} dx = \frac{e^{\operatorname{sgn}(x)x}}{\operatorname{sgn}(x)} + C = \operatorname{sgn}(x)e^{|x|} + C$$
edit: And well, this is broken.
