Skip to content

Mean-Variance Optimization

Markowitz mean-variance optimization chooses portfolio weights that minimise risk for a target expected return, or equivalently maximise return for a given risk. The problem is a constrained optimisation solved with the method of Lagrange multipliers, which converts the constraints into a system whose solution gives the optimal weights in closed form. This is the exact technique examined at the mid-term, so the mechanics of setting up the Lagrangian and reading off the weight vector matter as much as the concept. The output traces the set of efficient portfolios that no rational investor would reject.

Try it yourself

The efficient frontier

Sweep the weight w on asset A to trace the frontier of risk and return. A lower correlation ρ bows it toward the return axis, the diversification benefit. The minimum-variance portfolio is its leftmost point.

Current portfolio (wA = 0.50)11.0% · σ 13.5%
7%9%11%13%15%0%6%12%18%25%Risk σ (%)Expected return E(R) (%)ABMVPFrontierCurrentMVP
MVP risk σ 11.3%MVP weight w* 0.83
Weight on A, w0.50
Correlation ρ0.20
E(R) of A8.0%
σ of A12.0%
E(R) of B14.0%
σ of B22.0%
Risk is below the weighted-average volatility whenever ρ < 1. The frontier bends most as ρ falls toward −1, where the right mix drives risk close to zero. The MVP holds w* = 0.83 in A.
Try this. Set ρ = +1 — the frontier collapses to a straight line, so there is no diversification benefit. Now set ρ = −1 — it bends sharply and the right mix can push risk almost to zero.

Why it matters

You want the lowest-risk mix that still hits your return goal, and the constraints are that the weights add to one and the expected return equals your target. Lagrange multipliers are the standard trick for optimising subject to such constraints, attaching a multiplier to each constraint and turning a hard problem into solving linear equations. The multipliers also have meaning as shadow prices, telling you how much extra risk you must accept to raise the return target by a unit. Once you can build the Lagrangian and invert the resulting system you can compute the optimal weights for any target, which is what the mid-term asks.

Formulas

Mean-variance problem
minw  12wTΣws.t.wTμ=μp,    wT1=1\min_{\mathbf{w}}\; \tfrac{1}{2}\,\mathbf{w}^{\mathsf{T}}\boldsymbol{\Sigma}\,\mathbf{w} \quad \text{s.t.} \quad \mathbf{w}^{\mathsf{T}}\boldsymbol{\mu}=\mu_p, \;\; \mathbf{w}^{\mathsf{T}}\mathbf{1}=1
Minimise portfolio variance subject to a target mean μp\mu_p and weights summing to one. Σ\boldsymbol{\Sigma} is the covariance matrix and μ\boldsymbol{\mu} the vector of expected returns.
Lagrangian
L=12wTΣwλ ⁣(wTμμp)γ ⁣(wT11)\mathcal{L} = \tfrac{1}{2}\,\mathbf{w}^{\mathsf{T}}\boldsymbol{\Sigma}\,\mathbf{w} - \lambda\!\left(\mathbf{w}^{\mathsf{T}}\boldsymbol{\mu}-\mu_p\right) - \gamma\!\left(\mathbf{w}^{\mathsf{T}}\mathbf{1}-1\right)
One multiplier λ\lambda for the return constraint and one multiplier γ\gamma for the budget constraint. Setting the gradient to zero gives the first-order conditions.
Optimal weights from the first-order conditions
w=Σ1 ⁣(λμ+γ1)\mathbf{w}^{*} = \boldsymbol{\Sigma}^{-1}\!\left(\lambda\,\boldsymbol{\mu} + \gamma\,\mathbf{1}\right)
Solve L/w=0\partial\mathcal{L}/\partial\mathbf{w}=\mathbf{0} for w\mathbf{w}, then pin down λ\lambda and γ\gamma from the two constraints. This is the closed-form mid-term solution.

Worked examples

Scenario

State the Lagrangian for minimising variance subject to a target return and a budget constraint, then say how the optimal weights are found.

Solution

Write L=12wTΣwλ(wTμμp)γ(wT11)\mathcal{L}=\tfrac12\mathbf{w}^{\mathsf{T}}\boldsymbol{\Sigma}\mathbf{w}-\lambda(\mathbf{w}^{\mathsf{T}}\boldsymbol{\mu}-\mu_p)-\gamma(\mathbf{w}^{\mathsf{T}}\mathbf{1}-1). Setting L/w=Σwλμγ1=0\partial\mathcal{L}/\partial\mathbf{w}=\boldsymbol{\Sigma}\mathbf{w}-\lambda\boldsymbol{\mu}-\gamma\mathbf{1}=\mathbf{0} gives w=Σ1(λμ+γ1)\mathbf{w}^{*}=\boldsymbol{\Sigma}^{-1}(\lambda\boldsymbol{\mu}+\gamma\mathbf{1}). Substituting back into the two constraints yields two linear equations in λ\lambda and γ\gamma, which you solve and plug in to get the numeric weights.

Scenario

For two uncorrelated assets with equal expected returns and σ1=10%\sigma_1=10\%, σ2=20%\sigma_2=20\%, find the minimum-variance weights.

Solution

With zero correlation the minimum-variance weight on asset 1 is w1=σ22/(σ12+σ22)=0.04/(0.01+0.04)=0.8w_1=\sigma_2^2/(\sigma_1^2+\sigma_2^2)=0.04/(0.01+0.04)=0.8. So hold 80% in the lower-risk asset and 20% in the higher-risk one. The optimiser tilts toward the calmer asset, exactly as the Lagrange solution predicts when returns are equal.

Common mistakes

  • Mean-variance optimisation just picks the highest-return assets. It minimises risk for a given return target, so a low-return asset can earn a large weight when it lowers portfolio variance.
  • The Lagrange multipliers are only a mathematical device with no meaning. Each multiplier is a shadow price, showing how the minimised variance responds to tightening the return or budget constraint.
  • The optimal weights must all be positive. Unless short sales are restricted, the closed-form solution can assign negative weights, meaning some assets are sold short.
  • A single optimal portfolio exists for every investor. The optimiser produces a different efficient portfolio for each return target, so the result is a whole frontier rather than one point.

Revision bullets

  • Minimise portfolio variance subject to a target return and weights summing to one
  • Lagrange multipliers convert the constraints into solvable first-order conditions
  • Optimal weights are the inverse covariance matrix times a combination of returns and ones
  • The multipliers are shadow prices on the return and budget constraints
  • Solving across return targets traces out the efficient set, the exact mid-term method

Quick check

In Markowitz mean-variance optimisation, the Lagrange-multiplier method is used to

The closed-form optimal weight vector takes the form

Connected topics

Sources

  1. Markowitz, H. Portfolio Selection. Journal of Finance, 7(1), 77-91, 1952.
    Originates mean-variance portfolio selection and the optimisation of weights under constraints.
  2. Brailsford, Heaney & Bilson (2015), Ch. 8
    Brailsford, T., Heaney, R., & Bilson, C. Investments: Concepts and Applications. 5th ed. Cengage Learning Australia, 2015.
    Presents the constrained optimisation and the Lagrange solution for the optimal weights.
How to cite this page
Dr. Phil's Quant Lab. (2026). Mean-Variance Optimization. Derivatives Atlas. https://phucnguyenvan.com/concept/im-mean-variance