# For set $X$ of integers, why is the square of the sum of its elements equal to the sum of pairwise products?

title pretty much says it all:

$\sum_{i \in X} \sum_{j \in X} ij = (\sum_{i \in X}i)^2$

I'm trying to find out why two ways of writing the same formula are identical, and this is what it comes down to. I find this to be true for all cases I look at (and I assume it is, because the equality of the two original formulations is pretty well-established), but I have no idea why, nor how to proceed such a kind of question.

-
This can be demonstrated very neatly by a graphical argument: Draw a square with sides $\sum_{i\in X}i$, and calculate the area in 2 different ways. – John Wordsworth Jun 14 '12 at 16:55
thanks @OldJohn, beautiful visualization! – Nicolas Jun 14 '12 at 17:26

## 1 Answer

This is simply the distributive law in action. Take each term of the left factor and multiply by each term in the right factor where both factors are the sum of the elements of the set.

-
 doh! of course, thanks! – Nicolas Jun 14 '12 at 17:26