# Moment generating function of the absolute value of a continuous random variable

Let $X$ be a continuous random variable with the density $$f_X(x)=\begin{cases}\frac{1}{2}e^x \quad \text{if } x<0\\e^{-2x} \quad \text{if } x>0\end{cases}$$ What are the moment generating functions of $X$ and $|X|$? In what range is each moment generating function defined?

-

To complement the usual approach, note that $X=UY$ where $U$ and $Y$ are independent, $Y$ is a standard exponential random variable and $\mathbb P(U=\frac12)=\mathbb P(U=-1)=\frac12$.
This yields readily the moment generating functions. For example, conditioning on $U$, $$M_X(t)=\mathbb E(\mathrm e^{tX})=\mathbb E(\mathbb E(\mathrm e^{tX}\mid U))=\mathbb E(M_Y(tU)).$$ Since $M_Y(t)=1/(1-t)$ for every $t\lt1$, this yields, for every $-1\lt t\lt2$, $$M_X(t)=\mathbb E\left(\frac1{1-tU}\right)=\frac12\frac1{1-\frac12t}+\frac12\frac1{1+t}.$$ Likewise, for every $t\lt1$, $$M_{|X|}(t)=\mathbb E(\mathrm e^{t|X|})=\mathbb E\left(\frac1{1-t|U|}\right)=\frac12\frac1{1-\frac12t}+\frac12\frac1{1-t}.$$
Let $M:=M_X$ the moment generating function, and $f:=f_X$. By definition, for a $t\in\Bbb R$, $$M(t)=E\big(e^{tX}\big)=\int_{\Bbb R} e^{tx}\cdot f(x)dx = \int_{-\infty}^0 .. +\int_0^{+\infty}..$$ Can you continue?
For $|X|$, $$M_{|X|}(t)=E\big(e^{t|X|}\big)=\int_{\Bbb R}e^{t|x|}\cdot f(x)dx=...$$ and split it again for $x>0$ and $x<0$.