Mean-
variance optimisation finds the weights with the smallest variance for a specified
expected return. With a fully invested portfolio, unrestricted
short selling, and a positive-definite
covariance matrix, two Lagrange multipliers give the exact solution. One enforces the target return and the other enforces that the weights sum to one. Long-only limits turn the problem into a constrained quadratic programme.
Set up the two constraints and solve the multipliers
Let w be the weight vector, μ the expected returns, Σ the covariance matrix and m the target return. Solve
wmin21w⊤Σw,1⊤w=1,μ⊤w=m.
The Lagrangian is
21w⊤Σw−λ(μ⊤w−m)−γ(1⊤w−1).
Stationarity gives
w=Σ−1(λμ+γ1).
Define A=1⊤Σ−11, B=1⊤Σ−1μ, and C=μ⊤Σ−1μ. Substitution into the constraints yields Aγ+Bλ=1 and Bγ+Cλ=m. With D=AC−B2>0,
γ=DC−Bm,λ=DAm−B,σp2(m)=DAm2−2Bm+C.
The
global minimum-variance portfolio has return
B/A. The efficient branch consists of targets
m≥B/A. Below that return, moving towards the minimum-variance point increases expected return and decreases variance. When all assets have the same expected return, the return constraint is either redundant or infeasible and
D=0.
Differentiating
21w⊤Σw gives
Σw because
Σ is symmetric. The two linear constraints contribute multiples of
1 and
μ. Solving for
w at fixed multipliers therefore gives a
linear combination of
Σ−11 and
Σ−1μ. Substituting that combination back into the budget and return equations produces a two-by-two system. Its determinant is positive when
μ is not proportional to
1 and
Σ is positive definite. In computation, solve the linear systems rather than forming an explicit
matrix inverse.
There is a useful boundary case before you invert the two-by-two matrix. If all assets have the same expected return, the return constraint is proportional to the budget constraint. Every fully invested portfolio then has the same expected return. A target at that return leaves only the global minimum-variance problem, while any other target is infeasible. This is why a zero determinant needs interpretation. Adding a small numerical constant to force the two-multiplier formula through would hide the fact that the two constraints are carrying the same information.
Check the solution on a two-asset target
Suppose equities have an expected return of 8% and
volatility of 18%, bonds have an expected return of 4% and volatility of 8%, and their
correlation is 0.20. The 6% return target forces an even split. The covariance is
0.20(0.18)(0.08)=0.00288. The resulting variance is
0.01114 and volatility is about 10.55%. The global minimum-variance portfolio allocates about 10.65% to equities, giving an expected return of roughly 4.43%. The 6% target sits on the efficient branch.
Solve the two constraints in Python
Solve the linear systems directly to avoid forming a matrix inverse.
import numpy as np
mu = np.array([0.08, 0.04])
cov = np.array([[0.0324, 0.00288], [0.00288, 0.0064]])
constraints = np.column_stack([np.ones(mu.size), mu])
basis = np.linalg.solve(cov, constraints)
multipliers = np.linalg.solve(constraints.T @ basis, [1.0, 0.06])
weights = basis @ multipliers
print(weights, np.sqrt(weights @ cov @ weights))
References and next steps