Q)How to integrate $$\int e^{|x|}dx$$?
Ans) First of all let me tell everyone that this question suddenly came in my mind because in my school life I have learnt how to integrate $\int e^{x}dx$ and also I have learnt how to integrate $\int e^{-x}dx$. The result of $\int e^{x}dx=e^{x}+C$ and the result of $\int e^{-x}dx=-e^{-x}+C$. I am not showing the step by step solutions of these questions because these questions are very much easy. The solutions are also of a single step. Now let me come into my question.
$1^{st}$ process:
We know that the definition of $|x|$ is
$$f(x)=|x|= \begin{cases} x, & \text{if $x>0$} \\[2ex] 0, & \text{if $x=0$} \\[2ex] -x, & \text{if $x<0$} \end{cases} $$. Therefore the definition of $e^{|x|}$ will be $$f(x)=e^{|x|}= \begin{cases} e^{x}, & \text{if $x>0$} \\[2ex] 1 , & \text{if $x=0$} \\[2ex] \frac{1}{e^{x}}, & \text{if $x<0$} \\[2ex] \end{cases} $$. Therefore, there will be $3$ results occuring for $\int e^{|x|}dx$.
When $x>0$ then $\int e^{|x|}dx=\int e^{x}dx=e^{x}+C$.
When $x=0$ then $\int e^{|x|}dx=\int e^{0}dx=x+C$.
When $x<0$ then $\int e^{|x|}dx=\int e^{-x}dx=-e^{-x}+C$.
$2^{nd}$ process:
We know that $e^{x}=1+x+\frac{x^{2}}{2!}+\frac{x^{3}}{3!}+...\infty$.
Therefore we can say that $e^{|x|}=1+|x|+\frac{(|x|)^{2}}{2!}+\frac{(|x|)^{3}}{3!}+...\infty$.
Therefore we can integrate now $e^{|x|}dx$ easily from this expansion.
$\int e^{|x|}dx=\int 1dx+ \int |x|dx+ \int\frac{(|x|)^{2}}{2!}dx+ \int\frac{(|x|)^{3}}{3!}dx+...\infty$.
Therefore,
$\int e^{|x|}dx= x+C_1 + \frac{x^{2}sgn(x)}{2}+C_2 + \frac{x^{3}}{6}+C_3 + \frac{x^{4}sgn(x)}{24}+C_4 +...\infty$
But I am confused whether my $2^{nd}$ process is correct or not. Also in the $2^{nd}$ process I am not getting the option to write the integral constant $i.e.$ $+C$, because $C_1+C_2+C_3+C_4+...$ will be equal to $+C$ . Wolfram Alpha is giving an answer which is different from my methods.
Please help me out with this integral.
Let $u=|x|$ then $du=\frac x{|x|}dx\operatorname{sgn}(x)dx$ for $x\neq 0$ or equivalently $dx=\operatorname{sgn}(x)du.$ Then $$\int e^{|x|}dx=\int \operatorname{sgn}(x)e^udu$$ Since $\operatorname{sgn}(x)$ is just a constant, we can take it out and have $$\operatorname{sgn}(x)\int e^udu=\operatorname{sgn}(x)e^u+C=\operatorname{sgn}(x)e^{|x|}+C.$$