# How to prove an equality envolving variance and covariance

I'm having trouble following the last step of this proof provided by Sarwate in this topic: https://stats.stackexchange.com/questions/160230/variance-of-linear-combinations-of-correlated-random-variables.

Basically, I can't see why

$$\sum_{i=1}^n\sum_{j=1}^na_ia_jcov(X_i,X_j)=\sum_{i=1}^na_i^2var(X_i)+2\sum_{i=1}^n\sum_{j>1}^na_ia_jcov(X_i,X_j)$$

Things that I know that I think might be useful:

• $var(aX)=a^2var(X)$
• $cov(X,X)=var(X)$

And other properties of variance and covariance.

I think what's making it difficult for me to prove it is the fact that I'm not sure how to expand the double summation on the right side in terms of $n$. Any help will be appreciated.

Thanks very much

• It is just symmetry of the covariance. – Ian Apr 3 '17 at 4:26

$$\sum_{i=1}^n \sum_{j=1}^n a_i a_j \operatorname{Cov}[X_i,X_j] = \sum_{i=1}^n a_i^2 \operatorname{Var}[X_i] + 2 \sum_{i=1}^{n\color{red}{-1}}\sum_{j>\color{red}{i}}^n a_i a_j \operatorname{Cov}[X_i,X_j]$$ The major error is the inner sum's lower index: this must be $j > i$. Although it is not an absolute necessity that the upper index of the outer sum be written as $n-1$ (since if $i = n$, the inner sum over $j$ is empty), it is clearer to let $i$ range from $1$ to $n-1$.
The double sum on the RHS is sometimes written in a more succinct fashion as $$\sum_{1 \le i < j \le n} a_i a_j \operatorname{Cov}[X_i, X_j]$$ or even $$\sum_{i < j} a_i a_j \operatorname{Cov}[X_i, X_j]$$ although the latter is somewhat informal.
To understand the underlying intuition, consider the following $n \times n$ matrix: $$\begin{bmatrix} c_{11} & c_{12} & \ldots & c_{1n} \\ c_{21} & c_{22} & \ldots & c_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ c_{n1} & c_{n2} & \ldots & c_{nn} \\ \end{bmatrix}$$ Now suppose $c_{ij} = c_{ji}$ for all $i,j$, so that the matrix is symmetric. Then the sum of the entries in this matrix can be written as $$\sum_{i=1}^n \sum_{j=1}^n c_{ij},$$ which is equivalent to summing the rows, then summing the total of the rows. But since the matrix is symmetric, we can also compute the sum by taking the sum of the main diagonal, plus twice the sum of one the triangular regions on either side of the diagonal; that is to say, $$\sum_{i=1}^n c_{ii} + 2\sum_{i=1}^{n-1} \sum_{j=i+1}^{n} c_{ij}.$$ And this is why your formula looks the way it does: it is simply a reordering of the terms of the sum by exploiting the symmetry of covariance, then observing that $\operatorname{Cov}[X_i, X_i] = \operatorname{Var}[X_i]$ for the diagonal terms.