Demonstrate Risk Formula in Markowitz Asset Pricing Model there!
I'm trying to demonstrate Markowitz Model's formula for the risk of a portfolio with $N$ assets. Considering that the risk can be measured in terms of the variance of the portfolio ($\sigma^2_P$), the percentage of the $i$-th asset ($i=1,2,\ldots,N$) on the portfolio value ($X_i$), the variance of the $i$-th asset ($\sigma^2_i$) and the covariance between the $j$-th and the $i$-th asset ($\sigma_{ij}$), $j \ne i$.
I tried to start the demonstration by assuming that the return of the portfolio is given by $R_P = \sum_{i = 1}^N X_i \cdot R_i$ and that the expected return of the portfolio if given by $E(R_P) = \sum_{i=1}^N X_i \cdot E(R_i)$.
After that, I remembered that $Var(X) = E\left[(X-E(X))^2\right]$, substituted $X = R_P$, which gave me the expression:
$\displaystyle \sigma^2_P = E\left[\left(R_P - E(R_P)\right)^2\right] = E\left[\left(\sum_{i=1}^{N} X_i \cdot R_i - \sum_{i=1}^{N} X_i \cdot E(R_i)\right)^2\right]$
I need to get to the expression:
$\displaystyle \sigma^2_P = \sum_{i=1}^N X_i^2\cdot\sigma^2_i + \sum_{i=1}^N\sum_{j=1}^N X_i \cdot X_j \cdot \sigma_{ij}$
Any ideas on how to get there? Thanks.
 A: We can write
$$\left(\sum_{i=1}^{N} X_i \cdot R_i - \sum_{i=1}^{N} X_i \cdot E(R_i)\right)^2 = \left(\sum_{i=1}^{N} X_i \,[R_i -  E(R_i)]\right)^2 = \\ \sum_{i=1}^{N}\sum_{j=1}^N X_iX_j \, [R_i -  E(R_i)][R_i -  E(R_i)] \\ = \sum_{i=1}^NX_i^2[R_i -  E(R_i)]^2 + \underset{i \neq j}{\sum_{i=1}^{N}\sum_{j=1}^N} X_iX_j \, [R_i -  E(R_i)][R_i -  E(R_i)] $$
The variance $\sigma_i^2$ and covariance $\sigma_{ij}$ ($i\neq j$) are defined as
$$\sigma_i^2 = E\left([R_i -  E(R_i)]^2\right), \quad \sigma_{ij} = E\left([R_i -  E(R_i)][R_j -  E(R_j)]\right)$$
Thus,
$$\sigma_p^2 = E\left(\sum_{i=1}^NX_i^2[R_i -  E(R_i)]^2 + \underset{i \neq j}{\sum_{i=1}^{N}\sum_{j=1}^N} X_iX_j \, [R_i -  E(R_i)][R_i -  E(R_i)]  \right) \\ = \sum_{i=1}^NX_i^2\, E\left([R_i -  E(R_i)]^2\right) + \underset{i \neq j}{\sum_{i=1}^{N}\sum_{j=1}^N} X_iX_j \, E \left([R_i -  E(R_i)][R_i -  E(R_i)]\right) \\ = \sum_{i=1}^NX_i^2\, \sigma_i^2 + \underset{i \neq j}{\sum_{i=1}^{N}\sum_{j=1}^N} X_iX_j \, \sigma_{ij}$$
Note that the double sum on the RHS is taken over terms where $i \neq j$.
