We now finally encounter a classical topic in finance, mean variance analysis. This has had to wait because we needed the tool of a linear algebra class before dealing with this.
Mean variance analysis is very simple when expressed in vector format.
In the case where there are no short sales constraints, the minimum variance portfolio for any given expected return has an analytical solution and is therefore easy to generate.
The portfolio given the expected return is found as
For the mathematics of generating the unconstrained MV frontier, see chapter 3 of Huang and Litzenberger (1988).
When constraining the short sales, we need to solve a quadratic program.