I have the following density function: $$f_{x, y}(x, y) = \begin{cases}2 & 0\leq x\leq y \leq 1\\ 0 & \text{otherwise}\end{cases}$$
We know that $\operatorname{cov}(X,Y) = E[(Y - EY)(X - EX)]$, therefore we need to calculate E[X] and E[Y].
$$f_x(x)=\int_x^1 2\,\mathrm dy = \big[2y\big]_x^1 = 2-x, \forall x\in[0, 1]$$
$$E[X] = \int_0^1 x (2-x)\,\mathrm dx = \int_0^1 2x - x^2\,\mathrm dx= \left[\frac{2x^2}{2}-\frac{x^3}{3}\right]_0^1 = 1 - \frac{1}{3} = \frac23 $$
$$f_y(y) = \int_0^y\,\mathrm dx = \big[2x\big]_0^y = 2y, \forall y\in [0, 1]$$
$$E[Y] = \int_0^1 y\cdot2y\,\mathrm dy= \int_0^1 2y^2\,\mathrm dy= \left[\frac{2y^3}{3}\right]_0^1 = \frac23$$
However, the provided solution states that $E[X]=\dfrac13$. Have I done a mistake or is the solution wrong?
The continuation of the solution is:
$$\mathrm{cov}(X,Y) = \int_0^1\int_x^1(x-\frac 13)(y- \frac 23) \times 2\,\mathrm dy\,\mathrm dx$$
Where does the $\underline{2\,\mathrm dy\,\mathrm dx}$ come from?
Yes. $f_X(x)=\text{correct stuff}={[2y]}_{y=x}^{y=1}\mathbf 1_{x\in(0;1)}=(2-\color{crimson}2x)\mathbf 1_{x\in(0;1)}$ $$\mathsf E(X)=\int_0^1 x(2-\color{crimson}2x)\mathsf d x = \tfrac 13$$
It is from the joint probability density function. $$\mathsf {Cov}(X,Y)~{=~\iint_{\Bbb R^2} (x-\mathsf E(X))~(y-\mathsf E(Y))~f_{X,Y}(x,y)~\mathsf d(x,y)\\=\int_0^1\int_x^1 (x-\tfrac 13)~(y-\tfrac 23)~2~\mathsf dy~\mathsf d x\\=\tfrac 1{36}}$$