How did they derive the expression from sum of variances 
I have a question in my textbook to which I do not understand the solution. Here's the solution:



*

*(green) Why is 
i smaller than j 
. Since Cov(X,Y)=Cov(Y,X) by definition of covariance ? Is it supposed to be for convenience, the index?

*(yellow, under Y) Is this supposed to be a typo? I don't understand where it came from

*(whole expression underlined in red) How did they derive this? Also why is X not specified with indices? Since $X_i$ and $X_j$ are not the same for i not equal to j?
 A: *

*Yes, $Cov(X,Y) = Cov(Y,X)$ and so you end up with having to add a matrix of covariances, this connects the off-diagonal entries into one convenient block.

*Just bad notation. Think of a typical $(X_i,X_j)$ pair as $(X,Y)$ instead.

*Since all the $X_i$ are iid, they have the same variance, so
$$
\sum_{i=1}^n \mathop{var}(X_i) = n \mathop{var}(X)
$$
and there are $n(n-1)/2$ entries in the second sum, so doubling the result gives what they have.

A: As written it appears that the solution is showing the variance of the sum is equal to the sum of the variances. If that's the case then the book needs to be careful about the case where $i=j$. (https://stats.stackexchange.com/questions/31177/does-the-variance-of-a-sum-equal-the-sum-of-the-variances)
1) There is a factor of 2 to deal with the switching between $i$ and $j$
2) $Y$ is supposed to be a stand in variable for $X_j \neq X_i$
3) Presumably the $X_i$ are selected from the same distribution so $\text{var}(X_i) = \text{var}(X)$. The sum is over $n$ different $X_i$ so you get $n\text{var}(X)$.
For the other expression the sum is $\frac{n(n-1)}{2}$ multiply by the factor of 2 to get their expression.
