# 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.

• Rewrite your FOC as a linear equation system in matrix notation. Solve for $x$ using the blockwise matrix inversion theorem en.m.wikipedia.org/wiki/Block_matrix – Kermittfrog Nov 7 '20 at 7:54
• If that doesn’t help you I can elaborate in an answer – Kermittfrog Nov 7 '20 at 8:04
• @Kermittfrog could you please elaborate? I tried writing down the FOCs but couldn't see where I should apply the inversion theorem. Thank you so much for your help. – vpy Nov 8 '20 at 1:36

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{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}$$$$ and hence

$$$$\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}$$$$

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)$$

• FOC $L_w=\mathrm{\mu}-\mathrm{\Sigma}\mathrm{w}-\lambda\mathrm{e}=!=0$ doesn't match the first row of the linear system that follows because it missed $\gamma$ – develarist Nov 8 '20 at 7:57
• Yep, thanks. Corrected it. – Kermittfrog Nov 8 '20 at 8:27
• i see the "inverted matrix" and "constraint vector", but is there a name for the matrix consisting of $c$'s, and what its elements are for?. it looks like it is the inverted matrix – develarist Nov 10 '20 at 11:33
• It is the inverse of the FOC. – Kermittfrog Nov 10 '20 at 11:34