Skip to content
All library documents

Closed-Form Mean-Variance Portfolio Weights with a Budget Constraint

Article Quant Q&A · Author: vpy

Summary

The document derives the optimal portfolio for a mean-variance objective with a full-investment constraint. It sets the first-order conditions, represents them as a block linear system, and applies block-matrix inversion to eliminate the Lagrange multiplier. The resulting weights are expressed using the minimum-variance portfolio and a tangency portfolio, with the allocation shift scaled by risk aversion and the minimum-variance portfolio’s expected return relative to its variance.

The derivation assumes the covariance matrix is invertible and the constraint is feasible; it does not discuss additional restrictions such as bounds, short-sale limits, or transaction costs. The question’s notation initially uses the multiplier name for risk aversion, while the answer relabels the constraint multiplier, so keeping those roles distinct is important. The result applies to the stated unconstrained-in-weights problem with weights summing to one.

Key ideas

  • The first-order conditions form a linear system in portfolio weights and the budget multiplier.
  • Block-matrix inversion gives a closed-form solution without leaving the multiplier implicit.
  • Optimal weights combine the minimum-variance portfolio and the tangency portfolio.
  • Risk aversion scales the allocation shift away from the minimum-variance portfolio.
  • The formula addresses a full-investment constraint and does not include other portfolio restrictions.

Tags

Full text
# Derivation of mean-variance portfolio weights as closed-form analytical solution from Lagrangean equations


# Derivation of mean-variance portfolio weights as closed-form analytical solution from Lagrangean equations












I am trying to find a closed form solution for the constrained MVO problem below.

$\max_w w'\mu - \frac{\lambda}{2}w'\Sigma w $ s.t. $w'$1 = 1

The Lagrange for the objective is $L(w, \gamma) = w'\mu - \frac{\lambda}{2}w'\Sigma w -\gamma(w'$1 - 1).

The first order conditions are:

$\frac{\partial L}{\partial w} = \mu - \lambda \Sigma w - \gamma$ 1 = 0 Hence, $w = \frac{1}{\lambda}\Sigma^{-1}(\mu-\gamma$ 1) $\hspace{1cm} [1]$

$\frac{\partial L}{\partial \gamma} = w'$1 - 1 = 0 Hence, $w$'1 = 1 $\hspace{1cm} [2]$

Just to clarify, $\gamma$ is a real number; 1, $\mu$ have dimensions of Nx1; $\Sigma$ has dimension of NxN.

Substitute [1] into [2] $[\frac{1}{\lambda}\Sigma^{-1}(\mu-\gamma$ 1$)]'$1 = 1 $(\mu-\gamma 1)'\Sigma^{-1} $ 1 = $\lambda$

I am unable to express $\gamma \text{ in terms of } \Sigma, \mu, \lambda$, to substitute it into [1] to write a solution for $w$.

Any help is very much appreciated.

## Answer by Kermittfrog (score 5, accepted)

https://quant.stackexchange.com/a/59215

Let's stick with the nomenclature in the literature and let $\gamma$ denote the decision maker's risk aversion coefficient. The optimization problem is

$$ \max_{\mathrm{w}} \mathrm{w}^T\mathrm{\mu}-\frac{1}{2}\gamma \mathrm{w}^T\mathrm{\Sigma}\mathrm{w} \quad s.t. \mathrm{w}^T\mathrm{e}=1 $$ where $e$ denotes a vector of ones. The corresponding Lagrangean reads: $$ L(\mathrm{w},\lambda)= \mathrm{w}^T\mathrm{\mu}-\frac{1}{2}\gamma \mathrm{w}^T\mathrm{\Sigma}\mathrm{w} -\lambda\left( \mathrm{w}^T\mathrm{e}-1\right) $$

The first order conditions are linear: \begin{align} L_w&=\mathrm{\mu}-\gamma\mathrm{\Sigma}\mathrm{w}-\lambda\mathrm{e}=!=0\\ L_{\lambda}&=\mathrm{e}^T\mathrm{w}=!=1 \end{align}

We can formulate this as a linear system as: \begin{equation} \begin{pmatrix} \gamma\mathrm{\Sigma} & \mathrm{e}\\ \mathrm{e}^T & 0\end{pmatrix} \begin{pmatrix} \mathrm{w}\\ \lambda\end{pmatrix}=\begin{pmatrix}\mathrm{\mu} \\ 1\end{pmatrix} \end{equation} and hence

\begin{equation} \begin{pmatrix} \mathrm{w^*}\\ \lambda^*\end{pmatrix}= \begin{pmatrix} \gamma\mathrm{\Sigma} & \mathrm{e}\\ \mathrm{e}^T & 0\end{pmatrix}^{-1} \begin{pmatrix}\mathrm{\mu} \\ 1\end{pmatrix}=\begin{pmatrix}c_{11} & c_{12} \\ c_{21} & c_{22}\end{pmatrix}\begin{pmatrix}\mathrm{\mu} \\ 1\end{pmatrix} \end{equation}

This is where we use the block matrix inversion theorem . We know that $w^*$ is given by the first row of the inverted matrix times the constraint vector,

$$ \mathrm{w}^*=c_{11}\mathrm{\mu}+c_{12} $$ Looking up the two inversions from wiki, we find

$$ c_{11}=\frac{1}{\gamma}\mathrm{\Sigma}^{-1}-\frac{1}{\gamma}\mathrm{\Sigma}^{-1}\mathrm{e}\left(\mathrm{e}^T\frac{1}{\gamma}\mathrm{\Sigma}^{-1}\mathrm{e}\right)^{-1}\mathrm{e}^T\frac{1}{\gamma}\mathrm{\Sigma}^{-1} $$ and $$ c_{12}=\frac{1}{\gamma}\mathrm{\Sigma^{-1}}\mathrm{e}\left(\mathrm{e}^T\frac{1}{\gamma}\mathrm{\Sigma}^{-1}\mathrm{e}\right)^{-1}=\frac{\mathrm{\Sigma^{-1} e}}{\mathrm{e}^T\mathrm{\Sigma^{-1} e}} $$

Let us introduce the following

\begin{align} a&=\mathrm{e}^T\mathrm{\Sigma^{-1}}\mathrm{e}\\ b&=\mathrm{e}^T\mathrm{\Sigma^{-1}}\mathrm{\mu}\\ w_{MVP}&=\frac{\mathrm{\Sigma^{-1} e}}{\mathrm{e}^T\mathrm{\Sigma^{-1} e}}\\ w_{Tangency}&=\frac{\mathrm{\Sigma^{-1} \mu}}{\mathrm{e}^T\mathrm{\Sigma^{-1} \mu}} \end{align} Note that, conveniently, the two portfolios are the minimum-variance portfolio and the tangency portfolio. Then, $c_{12}\mu$ simplifies to $$ c_{12}\mathrm{\mu}=\frac{1}{\gamma}bw_{Tangency}-\frac{1}{\gamma}w_{MVP}b $$

and thus

$$ w^* = w_{MVP} + \frac{1}{\gamma}b\left(w_{Tangency}-w_{MVP}\right) $$

Finally, we note that $E(MVP)=\frac{b}{a}$, and $V(MVP)=\frac{1}{a}$. Thus, we may ultimately replace $b$ in equation above and arrive at

$$ w^* = w_{MVP} + \frac{1}{\gamma}\frac{\mu_{MVP}}{\sigma_{MVP}^2}\left(w_{Tangency}-w_{MVP}\right) $$

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.