I find that:

$$\Big(\sum_{i = 1}^n y_i\Big)^2 = \sum_{i=1}^m y_i^2 + \sum^m_{i\neq j}y_iy_j$$

where $m=(n^2-n)=n(n-1)$, the first part of the right side is the sum of the main diagonal of the matrix, and the second part is the sum of the upper and lower part of the matrix.

Then it is write that the second part can be written as:

$$\sum^m_{i\neq j}y_iy_j = 2\sum_{i=1}^n\sum_{j>i}^ny_iy_j$$

I think that this last point is not correct, in fact if we have $y_jy_i=k$, where $k$ is a constant we obtain:

$$ n(n-1)k \neq2n^2 $$

Furthermore, I think that $j = i-1$ should be better than $j>1$.

So, where is my mistake in the second part of the summation? And what about the $j$ index?

  • 2
    $\begingroup$ Did you mean to write "$j\gt i$" rather than "$j\gt 1$" beneath the second sum? $\endgroup$
    – whuber
    Feb 21, 2017 at 18:17

2 Answers 2


You have a good notion about diagonal and lower/upper part of matrix but your equations are wrong. Let $Y = [y_1, \dots, y_n]^T$, and

$$YY^T = \begin{pmatrix} y_1^2 & y_1y_2 & \cdots & y_1y_n \\ y_2y_1 & y_2^2 & \cdots & y_2y_n \\ \vdots & \vdots & \ddots & \vdots \\ y_ny_1& y_ny_2 & \cdots & y_n^2 \end{pmatrix}$$

Now you already said $(\sum_{i=1}^ny_i)^2$ is equal to sum of all elements of matrix $YY^T$. So it should be

$$(\sum_{i=1}^ny_i)^2 = \sum_{i=1}^ny_i^2 + \sum_{i=1}^n\sum_{j=i+1}^n y_iy_j + \sum_{i=1}^n\sum_{j=1}^{i-1} y_iy_j$$

where the right side terms are in order: diagonal elements, upper triangle and lower triangle elements. Now it's clear that $YY^T$ is symmetrical, thus

$$\sum_{i=1}^n\sum_{j=i+1}^n y_iy_j = \sum_{i=1}^n\sum_{j=1}^{i-1} y_iy_j$$

and note that we can also express it as

$$\sum_{i=1}^n\sum_{j=i+1}^n y_iy_j + \sum_{i=1}^n\sum_{j=1}^{i-1} y_iy_j = \sum_{\substack{ 1\le i \le n \\ 1\le j \le n \\ i \neq j }}y_iy_j = \sum_{i \neq j} y_iy_j$$

where the last sum is valid only when we assume index ranges are known implicitly. And lastly, we do not write

$$\sum_{i\neq j}^m y_iy_j$$

because the subsprict $i \neq j$ means we sum over a set

$$\{(i,j)\ |\ 1\le i,j \le n, i \neq j\}$$

and the $m$ doesn't bring any new information.

  • $\begingroup$ Now I have understand, but why you write $\sum_{i=1}^n\sum_{j=i+1}^n y_iy_j$? In fact, with this notation when $i = n$ we have $j=n+1$, and thid dimension does not exist. I think that it should be $\sum_{i=1}^{n-1}\sum_{j=i+1}^n y_iy_j$. Is it right or I am making some errors? Thanks in advance. $\endgroup$
    – Archimede
    Feb 24, 2017 at 10:53
  • 1
    $\begingroup$ @Archimede In general sum $\sum_{j=n+1}^{n} a_j = 0$, that is, we can ommit summation when lower index is greater than upper. And yes, you could write $\sum_{i=1}^{n-1}\sum_{j=i+1}^{n} y_iy_j$ instead. $\endgroup$ Feb 24, 2017 at 10:59

J should go like this - $ j = (i+1) \rightarrow n $ You don't have to use it like this, but this summation order insures the two values will multiply only once (think of it as the upper triangle of a matrix)

  • $\begingroup$ And what about $\sum^m_{i\neq j}y_iy_j = 2\sum_{i=1}^n\sum_{j>1}^ny_iy_j$ cannot be equal since $ n(n-1)k \neq2n^2 $ if $y_jy_i=k$ where $k$ is a constant? $\endgroup$
    – Archimede
    Feb 21, 2017 at 12:52
  • $\begingroup$ @Archimede the answer addresses that if you think about what you're asking. See also whuber's comment under the question. The expression you're asking about is in error. $\endgroup$
    – Glen_b
    Feb 22, 2017 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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