A single formula sits behind the calculation, analysing the variance, covariance and return for all assets together. It uses calculus to return the combination of assets with the minimum combined variance, maximum return, and everything between.
More detail is available here.