# 04 Portfolio optim.: Min. risk
###### tags: `Portfolio optimization`
In general, for $n$ assets, we can combine them to the overall return $\mu$ and risk $\sigma$:
$$
\left\{
\begin{array}{rcl}
\mu &=& \boldsymbol{\mu}^T \mathbf{w}\\
\sigma^2 &=& \mathbf{w}^T \Sigma \mathbf{w}
\end{array}
\right.
$$
where $\mathbf{w}=[w_1, \dots, w_n]^T$, $\boldsymbol{\mu}=[\mu_1, \dots, \mu_n]^T$, and $\Sigma$ is the covariance matrix of these $n$ assets.
Suppose we want to minimize the overall risk regardless of the overall return, then the problem can be formulated as follows:
$$
\min_{\mathbf{w}} \sigma^2=\mathbf{w}^T \Sigma \mathbf{w} \\
\text{s.t. }
\mathbf{1}^T \mathbf{w}=1\\
$$
where $\mathbf{1}=[1, \dots, 1]^T$.
To find the solution to this constrained optimization problem, we can formulate a new objective function using the Lagrange multiplier:
$$
\max_{\mathbf{w}, \lambda} J(\mathbf{w}, \lambda)=\mathbf{w}^T \Sigma \mathbf{w} + \lambda(\mathbf{1}^T \mathbf{w}-1).
$$
By taking the gradient and set it to zero, we have
$$
\nabla_\boldsymbol{w} J(\boldsymbol{w}, \lambda)=2\Sigma\mathbf{w}+\boldsymbol{1}\lambda=0 \Rightarrow
\mathbf{w}=-\frac{1}{2}\Sigma^{-1}\boldsymbol{1}\lambda
$$
Since $\mathbf{1}^T \mathbf{w}=1$, we have
$$
-\frac{1}{2}\boldsymbol{1}^T\Sigma^{-1}\boldsymbol{1}\lambda=1 \Rightarrow \lambda=-\frac{2}{\boldsymbol{1}^T\Sigma^{-1}\boldsymbol{1}}.
$$
Therefore
$$
\mathbf{w}=\frac{\Sigma^{-1}\boldsymbol{1}}{\boldsymbol{1}^T\Sigma^{-1}\boldsymbol{1}}
$$
And the corresponding minimum value of risk is as follows:
$$
\sigma^2=\mathbf{w}^T \Sigma \mathbf{w}
=\frac{\boldsymbol{1}^T\Sigma^{-1}}{\boldsymbol{1}^T\Sigma^{-1}\boldsymbol{1}} \Sigma
\frac{\Sigma^{-1}\boldsymbol{1}}{\boldsymbol{1}^T\Sigma^{-1}\boldsymbol{1}}
=\frac{1}{\boldsymbol{1}^T\Sigma^{-1}\boldsymbol{1}}
$$
(Note that $\boldsymbol{1}^T\Sigma^{-1}\boldsymbol{1}$ is equal to the sum of all elements in $\Sigma^{-1}$.)