Efficient frontier (source code)

= Efficient frontier
{title2=$v_{\min}(m)=x^2/A+(A/D)(m-Bx/A)^2$}
{wiki}

= Mean-variance efficient frontier
{synonym}

With fixed budget $s^T\pi=x$, positive definite covariance $V$, and mean vector $\mu$ independent of $s$, set $A=s^TV^{-1}s$, $B=s^TV^{-1}\mu$, $C=\mu^TV^{-1}\mu$ and $D=AC-B^2>0$. The minimum variance at mean $m$ is the displayed parabola. Its upper-mean branch $m\ge Bx/A$ is efficient: the lower branch has a competitor with equal variance and higher mean. If $\mu$ is proportional to $s$, only one mean is feasible and this two-dimensional parabola degenerates.

The efficient frontier is the set of portfolios for which no other feasible portfolio has at least as much expected return and no greater variance, with at least one strict improvement.