How to integrate: $\int_{0}^{\infty}e^{tx}(x^2e^{-x})/2dx$ I'm working on a few moment generating function problems and I came across:
$f(x)=(x^2e^{-x})/2$ for $x>0$, and zero otherwise.
Find the mean. The mean is the same as the expected value. If we find the moment generating function, $M_x(t)$, of $f(x)$ then we can take the first derivative of $M_x(t)$ at $t=0$. This will give us the mean.
To find the $M_x(t)$ we take $$\int_{-\infty}^{\infty}e^{tx}f(x)dx$$
$$\int_{0}^{\infty}e^{tx}(x^2e^{-x})/2dx$$
I wrote this as:
$$\frac12\int_{0}^{\infty}x^{2}e^{x(t-1)}dx$$
I'm a bit rusty on integration and if someone could help point me in the right direction as to how to tackle this guy I would greatly appreciate it!
 A: Integrate by parts two times:
\begin{aligned}
I & = \frac{1}{2}\int_0^\infty x^2e^{x(t-1)}dx = \\
  & = \frac{1}{2}\left[x^2\frac{e^{x(t-1)}}{t-1}\right]^{x=\infty}_{x=0} - \frac{1}{2}\int_0^\infty 2x\frac{e^{x(t-1)}}{t-1}dx = \\
  & = -\frac{1}{2}\left[2x\frac{e^{x(t-1)}}{(t-1)^2}\right]^{x=\infty}_{x=0} + \frac{1}{2}\int_0^\infty 2\frac{e^{x(t-1)}}{(t-1)^2}dx = \\
  & = \frac{1}{2}\left[2\frac{e^{x(t-1)}}{(t-1)^3}\right]^{x=\infty}_{x=0} = \\
  & = -\frac{1}{(t-1)^3}
\end{aligned}
Note that $t<1$ is required for convergence.
A: Your integral is equal to $$\frac{\mathcal{L}(x^2)}{2} = \frac{1}{2}\frac{2}{-(t-1)^3} = \frac{-1}{(t-1)^3}.$$
A: Let $u=x(1-t)\;\Rightarrow\;du=(1-t)\ dx$, then
\begin{align}
\frac12\int_{x=0}^\infty x^2e^{x(t-1)}\ dx&=\frac12\int_{u=0}^\infty\left(\frac u{1-t}\right)^2e^{-u}\cdot\frac{du}{1-t}\\
&=\frac1{2(1-t)^3}\int_{u=0}^\infty u^2e^{-u}\ du\\
&=\frac1{2(1-t)^3}\cdot\Gamma(3)\\
&=\frac1{2(1-t)^3}\cdot2!\\
&=\large\color{blue}{\frac1{(1-t)^3}},
\end{align}
where $t<1$ for the convergence.
A: Given
$$
M_x(t) = \tfrac{1}{2} \int_0^\infty e^{tx} x^2 e^{-x} dx
$$
Note that
$$
M_x(t) = \tfrac{1}{2} \frac{d^2}{dt^2} \int_0^\infty e^{[t-1]x} dx;\ t \le 1
$$
Whence
$$
M_x(t) = \tfrac{1}{2} \frac{d^2}{dt^2} \left( \frac{1}{1-t} \right) = \frac{1}{\Big(1-t\Big)^3};\ t \le 1
$$
