TITLE: What is the square of summation?
QUESTION [26 upvotes]: Consider the following, which one of the following is true ??

$$\left(  \sum^{n-1}_{j=0}Z_j\right)^2 = \sum^{n-1}_{j=0} Z_j^2 +  \sum^{n-1}_{j\neq i} Z_i Z_j$$
OR
$$\left(  \sum^{n-1}_{j=0}Z_j\right)^2 = \sum^{n-1}_{j=0} Z_j^2 +  \sum^{n-1}_{j< i} Z_i Z_j$$
There is a difference between $j \neq i $ and $j < i$ in the above expressions. But I dont know how to think through this.

REPLY [3 votes]: The following is correct, Using two sigmas instead of one as the following
$$\left(  \sum^{n-1}_{j=0}Z_j\right)^2 = \sum^{n-1}_{j=0} Z_j^2 +\sum^{n-1}_{j=0}\sum^{n-1}_{i\neq j} Z_jZ_i $$