I would like to perform a mean-variance analysis on a set of $n$ stocks, which consists of a constrained optimisation problem that is as follows:
Minimise expected portfolio variance $\sigma^2=\mathbf X^T \mathbf V \mathbf X$, subject to $\mathbf X^T \mathbf r=\mu$ and $\mathbf X^T \mathbf 1=1$, where $\mathbf X$ is a vector containing a weight for each of the $n$ stocks, $\mathbf V$ is the covariance matrix for the stocks (known), $\mathbf r$ is a vector of each stock's expected returns (known), $\mathbf 1$ is a vector of length $n$ whose every element is $1$, and $\mu$ is the expected portfolio return (a predetermined constant).
I've only recently begun teaching myself about optimisation, so I wouldn't know how to find the Lagrangian for this problem or solve it, but I have been given that it is:
$$\mathcal L = \mathbf X^T \mathbf V \mathbf X+2\lambda(\mu-\mathbf X^T \mathbf r)+2\eta(1-\mathbf X^T \mathbf 1)$$
where $\lambda$ and $\eta$ are the Lagrange multipliers. I have also been given that the solution is:
$$\mathbf X^{opt}=\frac{[(\mathbf r^T \mathbf V^{-1} \mathbf r) \mathbf V^{-1} \mathbf 1 - (\mathbf 1^T \mathbf V^{-1} \mathbf r) \mathbf V^{-1} \mathbf r] + \mu[(\mathbf 1^T \mathbf V^{-1} \mathbf 1)\mathbf V^{-1} \mathbf r-(\mathbf r^T \mathbf V^{-1} \mathbf 1)\mathbf V^{-1} \mathbf 1]}{(\mathbf r^T \mathbf V^{-1} \mathbf r)(\mathbf 1^T \mathbf V^{-1} \mathbf 1) - (\mathbf r^T \mathbf V^{-1} \mathbf 1)^2}$$
I'm using this solution directly to calculate the optimal $\mathbf X$. My issue is that I would like to add an additional constraint that no element of $\mathbf X$ can be negative, but I don't know how to correctly formulate this.
How can I express this extra constraint, and what would the resulting Lagrangian and problem solution look like?
Thanks!