Question: Can someone check whether my solutions for $E(X)$ is okay?

[![enter image description here](https://i.stack.imgur.com/NUhRn.png)](https://i.stack.imgur.com/NUhRn.png)

For (a), I found $E(X) = \frac{\theta +1}{\theta}$ and for (b), I applied integration by parts twice to get $2\theta ^{4}$. I feel as though (b) is wrong. Here is my work:

$E(X)=\theta^{2}\int\_{0}^{\infty}x^{2}e^{-\theta x}dx$

$=\theta^{2}(-\theta x^{2} e^{-\theta x}+2\theta (-\theta e^{-\theta x}x-\int\_{0}^{\infty}(-\theta e^{-\theta x})dx)$

$=[-\theta x^{2} e^{-\theta x}-2\theta ^{2} e^{-\theta x}x+2\theta ]\_{0}^{\infty}=\theta ^{2}(2\theta + 2\theta ^{2} -2\theta)=2\theta ^{4}$

Answer: 
Your computation can be substantially simplified by writing instead $$\operatorname{E}[X] = \int\_{x=0}^\infty x f(x;\theta) \, dx = \int\_{x=0}^\infty (\theta x)^2 e^{-\theta x} \, dx,$$ then choosing $$t = \theta x, \quad dt = \theta \, dx $$ yields $$\operatorname{E}[X] = \frac{1}{\theta} \int\_{t=0}^\infty t^2 e^{-t} \, dt.$$ Now this integral does not depend on $\theta$, thus you already know your answer cannot be correct. You would integrate by parts to obtain $$\begin{align\*}
\int\_{t=0}^\infty t^2 e^{-t} \, dt &= \left[ -t^2 e^{-t} \right]\_{t=0}^\infty + \int\_{t=0}^\infty 2t e^{-t} \, dt \\
&= 2 \left(\left[ -t e^{-t} \right]\_{t=0}^\infty + \int\_{t=0}^\infty e^{-t} \, dt \right) \\
&= 2 \left[ -e^{-t} \right]\_{t=0}^\infty \\
&= 2 (0 - (-1)) \\
&= 2. \end{align\*}$$ Thus the expectation is $\operatorname{E}[X] = 2/\theta.$

The error in your computation arises from the fact that you appear to have incorrectly calculated your choices for $v$; namely $$u = x^2, \quad du = 2x \, dx, \\ dv = e^{-\theta x} \, dx, \quad v = -\color{red}{\frac{1}{\theta}} e^{-\theta x}.$$ 

It is worth noting that the integral $\int\_{t=0}^\infty t^2 e^{-t} \, dt$ is a special case of the gamma function, namely $\Gamma(3) = 2!$.

Your
The integral in B can be interpreted as the Laplace transform of the function $f(x) = x^2$, just with $\theta$ as the transform variable instead of the usual $s$ seen in many differential equations texts. Nonetheless, a table lookup gives the Laplace transform of $x^2%$as $\frac{2}{\theta^3}$. Multiplying this by the $\theta^2$ on the outside gives the expectation of $\frac{2}{\theta}$.