The problem of finding the frontier of mean variance efficient portfolios was solved by Robert Merton 1972 in his paper "An Analytic Derivation of the Efficient Portfolio Frontier".The problem can be stated thus:
First let $\Omega$ be the matrix of covariances, and we assume it is positive definite and non-singullar.
\begin{align} (1) \qquad \min \quad & \frac{1}{2} \sigma^2 \\ \text{s.t.} \quad & \sigma^2 = \sum_{i = 1}^m \sum_{j = 1}^m x_i x_j \sigma_{ij} \\ &E = \sum_{i = 1}^m x_i E_i \\ & 1 = \sum_{i = 1}^m x_i \end{align}
where $x_i$ is the proportion of the value of the portfolio invested in asset $i$, $E_i$ is the expected return on asset $i$ and $\sigma_{ij}$ is the covariance between any two assets $i$ and $j$.
Using Lagrangian multipliers $(1)$ can be written as
$$(2) \qquad \min \frac{1}{2} \sum_{i = 1}^m \sum_{j = 1}^m x_i x_j \sigma_{ij} + \gamma_1[E - \sum_{i = 1}^m x_i E_i] + \gamma_2[1 - \sum_{i = 1}^m x_i]$$
where $\gamma_1$ and $ \gamma_2$ are lagrange multipliers.
The standard FOCs for a critical point are:
\begin{align} (3a) &&0 &= \sum_{j=1}^m x_j \sigma_{ij} - \gamma_1 E_i - \gamma_2 \qquad i = 1, ..., m \\ (3b) &&0 &= E - \sum_{i = 1}^m x_1 E_i \\ (3c) &&0 &= 1 - \sum_{i = 1}^m x_i \end{align}
Further, the x's that satisfy $(3)$ minimize $\sigma^2$ and are unique by the assumption on $\Omega$.
The system $(3)$ is linear in $x$ and hence we have from $(3a)$ that
$$(4) \qquad x_k = \gamma_1 \sum_{j = 1}^m v_{kj} E_j + \gamma_2 \sum_{j = 1}^m v_{kj}, \qquad k = 1, ..., m$$
Where $v_{ij}$ are defined as the elements of the inverse of the variance-covariance matrix $\Omega^{-1} \equiv [v_{ij}]$
Can someone explain how we get from $(3a)$ to $(4)$? I can't see how $\sum_{i =1}^m x_j \sigma_{ij}$ becomes $x_k$. Where do all the various $x_j \sigma_{ij}$ from the first term in $(3a)$ go?
Also does anyone know why were are minimizing $\frac{1}{2} \sigma^2$ rather than $\sigma^2$?
In matrix-vector form (3a) is
$$\Omega \mathbf{x} = \gamma_1 \mathbf{e} + \gamma_2 \mathbf{1},$$
where $\mathbf{e} = (E_1,\ldots, E_m)'$ and $\mathbf{1} = (1,\ldots,1)'$
Multiplying by the inverse $\Omega^{-1}$ we get
$$\mathbf{x} = \gamma_1 \Omega^{-1}\mathbf{e} + \gamma_2 \Omega^{-1}\mathbf{1},$$
which assumes the form of (4) in component form.
Minimizing $\frac{1}{2} \sigma^2$ and $\sigma^2$ are equivalent. The factor of $1/2$ is chosen for notational convenience to cancel the $2$ that arises upon differentiation of the variance.