Solving the integral of a function with modulus I would like to solve the following:
$$\int e^{-|x|}dx$$
The integral $\int e^{-x}dx = -e^{-x} +C$ is trivial, but the one with the modulus on $x$ seems to have a catch, as typing it into the integral calculator re-writes the integral and gives:
$$\frac{x}{|x|}\int e^{-|x|}\frac{|x|}{x}dx =-\frac{xe^{-|x|}}{|x|}$$
Why was the integral re-written like that? What would a general solution to future problems like this be?

This integral $$\int e^{-|x|}dx$$ is an even integral, such that we could define it as the amalgam of two integrals, each defined in a specific domain.
$$I_{1}=\int e^{-x}dx, x\geq 0 $$
$$I_{2}=\int e^{x}dx, x\leq 0 $$
As the question states, both these integrals are trivial.
$$I_{1}=- e^{-x} , x\geq 0 $$
$$I_{2}=e^{x}, x\leq 0 $$
We would like to write these two solutions as a single solution to the original integral. For this purpose, we need to appeal to some notation.
To begin with, we remember that, since we are on the Euclidean metric in one dimension, the magnitude the variable $x$ and the variable itself always have the same weight, such that
$$|x|= x , x\geq 0$$
$$|x|= -x , x\leq 0$$
In fact, we mae use of this very fact in order to establish that the integral was even.
But this property of the Euclidean Norm on the 1-D space means that
$$\frac{x}{|x|}= 1 , x> 0$$
$$\frac{x}{|x|}= 1 , x< 0$$
We then also note that
$$\lim_{x\rightarrow 0}\frac{x}{|x|}= 1$$
We can now return to the two integrals $I_{1}$ and $I_{2}$ and notice that they are both of the form
$$I = C e^{-|x|} $$
where $C = -1 $ when $x \geq 0$ and $ C = 1$ when $ x < 0 $. Thankfully, we already have a devise which has this property, so we employ is and claim that
$$I = -\frac{x}{|x|} e^{-|x|} +c_{1} $$
where we have also employed the arbitrary constant $c_{1}$ to highlight the fact that our integral is indefinite.
