Simple question about a formula for sums Why is
$$
\left(\sum_{i=1}^{n}a_i\right)^2= \sum_{i=1}^{n}\sum_{j=1}^{n}a_ia_j
$$
I guess it is fairly clear when you do it for $n=2$ for example, but I can't really proof it for all $n$ with induction.
 A: On the left-hand side we have $$(a_1+a_2+\cdots+a_n)(a_1+a_2+\cdots+a_n)$$  How do we multiply this out?  Pick a term in the first factor and a term in the second factor and multiply them.  Add up the products for all possible choices of two terms.  That's what the right-hand side says. 
A: NB: I give a proof by induction in the following. It may be a good exercise in order to practice induction, but the best way to understand the formula really is Saulspatz' point of view. 
We may prove this identity by induction on $n$. We will make use of the base case $n=2$, which you may check by yourself.  
The heredity is given by the following. Let $n>2$ be given and assume that the property holds for $n-1$. Let $a_1,\ldots, a_n$ be given real numbers, complex numbers, or elements of any commutative ring. We define $A_1 = a_1+\ldots +a_{n-1}$ and $A_2 = a_n$. Using the base case $n=2$, we may write 
$$\left(\sum_{i=1}^{n}a_i\right)^2=(A_1+A_2)^2=A_1^2 + A_1A_2+A_2A_1+A_2^2$$
Now, the induction hypothesis gives $A_1^2=\sum_{i=1}^{n-1}\sum_{j=1}^{n-1}a_ia_j$, and $A_2$ is no other than $a_n^2$.
As for $A_2A_1$, it is $\sum_{j=1}^{n-1}a_na_j$. We may see it as the term "$i=n$" in order to regroup it inside the sum defining $A_1^2$. At this point, we have 
$$\left(\sum_{i=1}^{n}a_i\right)^2= \sum_{i=1}^{n}\sum_{j=1}^{n-1}a_ia_j+A_1A_2+a_n^2$$
As you may know, because we are considering finite sums, we may invert the order of summations. Thus, this is also 
$$\left(\sum_{i=1}^{n}a_i\right)^2= \sum_{j=1}^{n-1}\sum_{i=1}^{n}a_ia_j+A_1A_2+a_n^2$$
But $A_1A_2$ is $\sum_{i=1}^{n-1}a_ia_n=\left(\sum_{i=1}^{n}a_ia_n\right)-a_n^2$. Again, we identify the term "$j=n$" so that we may eventually regroup all the terms 
$$\left(\sum_{i=1}^{n}a_i\right)^2= \sum_{i=1}^{n}\sum_{j=1}^{n}a_ia_j$$
which is our desired identity.
A: I am not sure why this is difficult to see.  Let $$A = \sum_{i=1}^n a_i, \quad B = \sum_{j=1}^n b_j.$$  Then $$AB = BA = B \sum_{i=1}^n a_i = \sum_{i=1}^n B a_i = \sum_{i=1}^n \left( a_i \sum_{j=1}^n b_j \right) = \sum_{i=1}^n \left( \sum_{j=1}^n a_i b_j \right) = \sum_{i=1}^n \sum_{j=1}^n a_i b_j.$$  All we have done here is repeatedly apply the distributive law.  Your identity is merely the special case where $a_i = b_i$ for each $i = 1, 2, \ldots, n$.  Proof by induction is unnecessarily complicated.
