Math Help - Correlation Co-efficient : Bivariate Contineous Probability Distribution?

1. Correlation Co-efficient : Bivariate Continuous Probability Distribution?

I am facing a problem to understand the formula to compute var(x) (variance of x). Any help in this regard would be highly appreciate

$
f(x,y) = x^{2}+\frac{xy}{3}, 0 < x < 1, 0 < y < 2, 0 \ elsewhere
$

Find var(x), var(y)

Solution:
$
g(x) = \int^{\infty}_{-\infty} f(x,y) dy = 2x^{2}+\frac{2}{3}x
$

$
h(y) = .......
$

$
E(x) = \int^{\infty}_{-\infty} x.g(x) dx = \frac{13}{18}
$

$
E(y) = ......
$

$
var(x) = E[x-E(X)]^2
$

$
= E(x-E(X))^2
$

$
= \int^{\infty}_{-\infty} (x-E(x))^2 . g(x) dx
$

$
= \int^{1}_{0} (x-\frac{13}{18})^2 . (2x^{2}+\frac{2x}{3}) dx
$

I am unable to understand how $
E(x-E(X))^2$
equals $\int^{\infty}_{-\infty} (x-E(x))^2 . g(x) dx$ ?

Once you marginalize the joint PDF $f(x,y)$ respect the r.v. X you obtain your univariate PDF g(x), from which you can compute the mean value of the r.v. X and then just compute the variance (see Variance - Wikipedia, the free encyclopedia).
The fact that $E(x-E(X))^2$ equals $\int^{\infty}_{-\infty} (x-E(X))^2 g(x) dx$ is by definition of the expectation operator (Expected value - Wikipedia, the free encyclopedia - see the part related to E{g(x)}).