Variance being negative 
Let $X$ and $Y$ have joint pdf such that 
$$f(x,y) = 3e^{-3x-y}, 0 < x< \infty, 0< y< \infty.$$
(a) Show that $X$ and $Y$ are independent.
(b) Calculuate $Var(X)$.

In problem $(b)$ I kept getting the result of $-\frac13$. But it is obvious that I should not get the negative variance, right??
You see, the pdf $f(x)$ should be $3e^{-3x}$ and $var(X)=E(X^2)-[E(X)]^2$
$E(X)=1,$
$\qquad E(X^2)=\frac23$
What's wrong with this??
 A: Note that $f(x) = \begin{cases} 3\exp(-3x) & x \ge 0 \\ 0 & x < 0\end{cases}$  is the pdf of an exponential distribution. 
The corresponding $E[X]= \frac1{\lambda}=\frac13$.
Also, the variance is supposed to be $\frac1{\lambda^2}=\frac19$.
That is  $E[X^2]-\frac19=\frac19$, $E[X^2]= \frac29$. Hence check the computation for the two moments.
It seems that you are missing by a factor of $\frac13$ for both terms.
A: @Siong Thye Goh provided a great start. This provides a bit more depth and isn't meant to replace the other answer. 
You have joint PDF $f_{X,Y}(x,y) = 3\text{e}^{-3x-y}$ for $x>0$ and $y>0$.
(a) You can recover the marginals (wiki page). 
$$f_X(x) = \int_0^\infty f_{X,Y}(x,y)dy$$ and
$$f_Y(y) = \int_0^\infty f_{X,Y}(x,y)dx$$
You will prove independence if you can show that the joint density is the product of the marginal densities, i.e. $f_X(x)f_Y(y) = f_{X,Y}(x,y)$.  
(b) I've no doubt you found $f_X(x) = 3\text{e}^{-3x}$ (WolframAlpha).
If you recognized this as $X\sim Exponential(\lambda=3)$ like @Siong Thye Goh then you're done as the mean and variance are known formulas using $\lambda$ (wiki).
If not, you can recover these from the PDF. 
$$ \text{E}(X) = \int_{-\infty}^\infty xf_X(x)dx=\int_0^\infty 3x\text{e}^{-3x}dx=\frac{1}{3}\quad \quad \left(\frac{1}{\lambda} \right) $$
We know $\text{Var}(X) = \text{E}[(X-\text{E}[X])^2] = \text{E}[X^2] - \text{E}[X]^2$ and we have $\text{E}[X]$. Using $\text{E}[g(X)] = \int_{-\infty}^\infty g(x)f_X(x)dx$, 
$$\text{E}(X^2) = \int_{-\infty}^\infty x^2 f_X(x)dx=\int_0^\infty 3x^2\text{e}^{-3x}dx=\frac{2}{9}\quad \quad \left(\frac{2}{\lambda^2} \right) $$
Then $\text{Var}(X) = \frac{2}{9} - \left(\frac{1}{3}\right)^2 = \frac{1}{9}$.
