Let $X = (X_1 X_2 \cdots X_n)^T$ be $n$ not necessarily independent investment vehicles. Assume each has expected return $\mu$ with covariance matrix $\operatorname{Var}(X)=(\operatorname{Cov}(X_i,X_j))_{i,j}$. What values of $0\leq c_1, \cdots, c_n \leq 1, c_1+\cdots +c_n=1$ minimizes the variance of the variable $Z=c_1X_1+\cdots +c_nX_n$?

Let $c=(c_1 \cdots c_n)$, I know that $Z=cX$ and that $\operatorname{Var}(Z)=c\operatorname{X}c^T=\sum_{i=1}^n\sum_{j=1}^nc_ic_j\operatorname{Cov}(X_i,X_j).$

Let $$f(c_1, \cdots, c_n)=\sum_{i=1}^n\sum_{j=1}^nc_ic_j\operatorname{Cov}(X_i,X_j),$$ then it suffices to find the partial derivatives of $f$:

$$\frac{\partial f}{\partial c_j}=\sum_{k=1}^n2\operatorname{Cov}(X_j,X_k)c_k, \ j=1,\cdots, n$$

But I had troubles finding the minimum of $f$ subjected to the constraint $c_1+\cdots+c_n=1$. I tried using Largange multiplier but it didn't seem to work. Thanks in advance.

  • $\begingroup$ It sounds like you're trying to minimize something of the form $c^T M c$ over a vector $c$ subject to $c^T c$. You can indeed do that with Lagrange multipliers (and I've made two answers over the last couple days on that) but the requirement that $0 \le c_i \le 1$ seems to turn it into a linear programming problem, which would need nastier methods. Also, I assume $c_i c_k$ should be $c_i c_j$ and $X_1$ should be $X_i$. $\endgroup$
    – David
    Aug 2, 2021 at 18:37
  • $\begingroup$ @David yes those were typos, updated just now thank you. $\endgroup$
    – Ishigami
    Aug 2, 2021 at 18:45
  • $\begingroup$ You might want to look into convex optimization $\endgroup$
    – Dasherman
    Aug 10, 2021 at 18:53

1 Answer 1


Setting up the Lagrange function (For $C_{ij} = Cov(X_i,X_j)$)

$$ \sum_{i=1}^n \sum_{j=1}^n c_i c_j C_{ij} - 2 \lambda \sum_{i=1}^n c_i $$

Taking the derivative w.r.t. $c_i$ and setting it to zero

$$ 2 c_{i} C_{ii} + 2 \sum_{j=1,i \neq j }^n c_j C_{ij} = 2 \lambda $$

Defining the matrix $C$, we can restate the system as $c \cdot C = \lambda \cdot 1_n $ where $1_n$ is the $n$-vector of ones.

Substituting back in the constraint, $c \cdot 1_n = \lambda \, 1_n \cdot C^{-1} \cdot 1_n = 1$ we arrive at the solution

$$ c = \frac{1}{1_n \cdot C^{-1} \cdot 1_n} \times 1_n \cdot C^{-1} $$

So, you can just sum columns of $C^{-1}$ to get the coefficients and normalize them.

  • $\begingroup$ Shouldn't the Lagrange equation be $\sum_{i=1}^n \sum_{j=1}^n c_ic_jC_{ij}-\lambda ((\sum_{i=1}^nc_i)-1)$? Since the constraint equation is $c_1+\cdots+c_n=1.$ $\endgroup$
    – Ishigami
    Aug 29, 2021 at 7:34
  • $\begingroup$ Yes, but the 1 doesn’t matter since we care about the derivative of the Lagrange function. $\endgroup$
    – Tohiko
    Aug 29, 2021 at 7:36
  • $\begingroup$ Thank you, but how did the $2$ show up in $2\lambda (c_1+\cdots+c_n)$? $\endgroup$
    – Ishigami
    Aug 29, 2021 at 7:43
  • $\begingroup$ Lambda is an arbitrary constant. I put 2 there to make calculations slightly easier. The result won’t change with or without 2. $\endgroup$
    – Tohiko
    Aug 29, 2021 at 7:45
  • 1
    $\begingroup$ Yes, that was a typo (the 2 is the reason I used 2 lambda). Corrected. $\endgroup$
    – Tohiko
    Aug 29, 2021 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.