An efficient portfolio is the asset weight distribution that minimises the variance (risk) of the overall portfolio given a required target return. It can be calculated as: \(\boldsymbol{A_mz_m = b}\)
Where \(\boldsymbol{A_m}\) is \(\begin{bmatrix} 2\boldsymbol{\Sigma} & \boldsymbol{\mu} & \boldsymbol{1} \\ \boldsymbol{\mu^t} & 0 & 0 \\ \boldsymbol{1^t} & 0 & 0\end{bmatrix}\)
\(\boldsymbol{\Sigma}\) is the covariance matrix, \(\boldsymbol{1}\) is an all one’s vector and \(\boldsymbol{1^t}\) its transpose.
\(\boldsymbol{\mu}\) is the asset mean returns vector and \(\boldsymbol{\mu^t}\) its transpose.
\(\boldsymbol{z_m}\) is the asset weights (plus two Lagrange Multipliers).
\(\boldsymbol{b}\) is a zero vector with the second last entry the portfolio target return and the last entry a one.
This equation is sloved for \(\boldsymbol{z_m}\) using LU decomposition and back substitution.