Suppose a random variable X has the pdf
$$f(x) = |x|, -1 \leq x \leq 1$$ and is 0 otherwise.
I want to find the moment generating function of X, then use this to find expectation and variance. I know that the moment generating function is $\Bbb E[e^{tX}]$, but I'm not sure how to calculate this in this situation. Likewise, I know to use the derivatives of this moment generating function to find expectation and variance (and will likely need to employ L'Hopital's rule), but I'm unsure how to find the moment generating function.
The moment generating function is as you say: $$m_X(t)=E(e^{tX})=\int_{-\infty}^\infty f(x)e^{tx}dx=\int_{-1}^1 |x|e^{tx}dx$$ You can split this integral up from $-1$ to $0$, and from $0$ to $1$ to deal with the absolute value; and in each case you can use integration by parts.