Linear algebra has various applications in real world. One of them is determining efficient frontier in portfolio diversification.
General theory says that efficient frontier is a set of optimal portfolio which offers highest expected return for a defined risk level or the one that offers lowest risk for a given expected return level.
In the code, optimal matrix is derived by minimizing standard deviation, given some expected return level for the Dow Jones 30 companies.
With x axis being the Standard Deviation and y axis being the Expectation values, the resulted efficient frontier for the Dow 30 is obtained as follows: