User: Extract the formulas in math latex markdown format to calculate the portfolio return and variance in Modern Portfolio Theory https://en.wikipedia.org/wiki/Modern_portfolio_theory
Assistant: - Expected return:
$$
\mathrm{E}\left(R_p\right)=\sum_i w_i \mathrm{E}\left(R_i\right)
$$
where $R_p$ is the return on the portfolio, $R_i$ is the return on asset $i$ and $w_i$ is the weighting of component asset $i$ (that is, the proportion of asset "i" in the portfolio, so that $\sum_i w_i=1$ ).
- Portfolio return variance:
$$
\sigma_p^2=\sum_i w_i^2 \sigma_i^2+\sum_i \sum_{j \neq i} w_i w_j \sigma_i \sigma_j \rho_{i j}
$$
where $\sigma_i$ is the (sample) standard deviation of the periodic returns on an asset $i$, and $\rho_{i j}$ is the correlation coefficient between the returns on assets $i$ and $j$. Alternatively the expression can be written as:
$$
\sigma_p^2=\sum_i \sum_j w_i w_j \sigma_i \sigma_j \rho_{i j}
$$
where $\rho_{i j}=1$ for $i=j$, or
$$
\sigma_p^2=\sum_i \sum_j w_i w_j \sigma_{i j}
$$
where $\sigma_{i j}=\sigma_i \sigma_j \rho_{i j}$ is the (sample) covariance of the periodic returns on the two assets, or alternatively denoted as $\sigma(i, j)$, $\operatorname{cov}{ }_{i j}$ or $\operatorname{cov}(i, j)$.
- Portfolio return volatility (standard deviation):
$$
\sigma_p=\sqrt{\sigma_p^2}
$$
For a two-asset portfolio:
- Portfolio return: 
$$\mathrm{E}\left(R_p\right)=w_A \mathrm{E}\left(R_A\right)+w_B \mathrm{E}\left(R_B\right)=w_A \mathrm{E}\left(R_A\right)+\left(1-w_A\right) \mathrm{E}\left(R_B\right)$$

- Portfolio variance: 
$$\sigma_p^2=w_A^2 \sigma_A^2+w_B^2 \sigma_B^2+2 w_A w_B \sigma_A \sigma_B \rho_{A B}$$
For a three-asset portfolio:
- Portfolio return: 
$$\mathrm{E}\left(R_p\right)=w_A \mathrm{E}\left(R_A\right)+w_B \mathrm{E}\left(R_B\right)+w_C \mathrm{E}\left(R_C\right)$$
- Portfolio variance: 
$$\sigma_p^2=w_A^2 \sigma_A^2+w_B^2 \sigma_B^2+w_C^2 \sigma_C^2+2 w_A w_B \sigma_A \sigma_B \rho_{A B}+2 w_A w_C \sigma_A \sigma_C \rho_{A C}+2 w_B w_C \sigma_B \sigma_C \rho_{B C}$$