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?

On $x \neq 0$, the derivative of $|x|$ is the mapping
$$ x \mapsto \begin{cases} 1 & x>0 \\ -1 & x<0\end{cases} $$
It can be written in various different ways; the expression $\frac{|x|}{x}$ is one such way.
One important feature of this function is that it is locally constant, which means you can use it in pretty much all of the ways you can use ordinary scalars — in particular, you can multiply it through the integral:
$$ \frac{|x|}{x} \int f(x) \, \mathrm{d}x
 = \int  \frac{|x|}{x} f(x) \, \mathrm{d}x $$
The reason for doing this is that having $e^{-|x|}$ in the integrand should immediately suggest making a substitution such as $u = |x|$ as a possible approach. Since we have
$$ \mathrm{d}u = \frac{|x|}{x} \mathrm{d} x$$
we rewrite the integral as
$$ \int e^{-|x|} \, \mathrm{d}x = \frac{x}{|x|}  \int e^{-|x|} \frac{|x|}{x} \, \mathrm{d}x  $$
so that we can make the substitution. Or equivalently, we don't do the rewriting, but we substitute
$$ \mathrm{d} x \mapsto \frac{x}{|x|} \mathrm{d}u  $$
One thing to be aware of is that the "constant of integration" is locally constant; since the domain $x \neq 0$ splits into two disjoint parts ($x>0$ and $x<0$), if you find one antiderivative $F$ on $x \neq 0$, the total solution on $x \neq 0$ is thus
$$ \int e^{-|x|} \, \mathrm{d}x = F(x) + C(x) $$
where $C(x)$ is a function of the form
$$ C(x) = \begin{cases} c_1 & x > 0 \\ c_2 & x < 0 \end{cases} $$
for constants $c_1$ and $c_2$.

Finally, to get an actual answer to the problem, you need to find an antiderivative that works for all $x$, not just on $x \neq 0$; that is, you need to find the conditions on the constant of integration so that the antiderivative can be continuously extended to have a value at $0$.
Your calculator has not done this final step; it only gave you an antiderivative on $x \neq 0$.
