# An identity involving products of sums

$$\left(\sum^n_{i=1}{a_i}^2\right)\cdot\left(\sum^n_{i=1}{b_i}^2\right)-\left(\sum^n_{i=1}{a_i}{b_i}\right)^2=\sum_{i<j}(a_i^2b_j^2+a_j^2b_i^2-2a_ib_ia_jb_j)$$

-
Try induction in $n$. – WimC Dec 8 '12 at 7:53

HINT: It may help to look first at a small example, say with $n=3$:

\begin{align*} &\left(\sum_{i=1}^3a_i^2\right)\left(\sum_{i=1}^3b_i^2\right)-\left(\sum_{i=1}^3a_ib_i\right)^2\\\\ &\qquad=\left(a_1^2+a_2^2+a_3^2\right)\left(b_1^2+b_2^2+b_3^2\right)-\left(a_1b_1+a_2b_2+a_3b_3\right)^2\\\\ &\qquad=\color{red}{a_1^2b_1^2+a_2^2b_2^2+a_3^2b_3^2}+\color{blue}{\left(a_1^2b_2^2+a_2^2b_1^2\right)+\left(a_1^2b_3^2+a_3^2b_1^2\right)+\left(a_2^2b_3^2+a_3^2b_2^2\right)}\\ &\qquad\qquad-\left[\color{red}{\left(a_1^2b_1^2+a_2^2b_2^2+a_3^2b_3^2\right)}+2a_1b_1a_2b_2+2a_1b_1a_3b_3+2a_2b_2a_3b_3\right]\\\\ &\qquad\color{blue}{\left(a_1^2b_2^2+a_2^2b_1^2\right)+\left(a_1^2b_3^2+a_3^2b_1^2\right)+\left(a_2^2b_3^2+a_3^2b_2^2\right)}\\ &\qquad\qquad-\Big(2a_1b_2a_2b_1+2a_1b_3a_3b_1+2a_2b_3a_3b_2\Big)\\\\ &\quad=\left(a_1^2b_2^2+a_2^2b_1^2-2a_1b_2a_2b_1\right)+\left(a_1^2b_3^2+a_3^2b_1^2-2a_1b_3a_3b_1\right)+\left(a_2^2b_3^2+a_3^2b_2^2-2a_2b_3a_3b_2\right)\\\\ &\quad=\sum_{1\le i<j\le 3}\left(a_i^2b_j^2+a_j^2b_i^2-2a_ib_ja_jb_i\right) \end{align*}\tag{1}

This should suggest that you want to split $$\left(\sum^n_{i=1}{a_i}^2\right)\left(\sum^n_{i=1}{b_i}^2\right)$$ splits into three parts: the terms $a_i^2b_j^2$ with $i=j$, those with $i<j$, and those with $i>j$. If you do so, you get

\begin{align*} \left(\sum^n_{i=1}a_i^2\right)\left(\sum^n_{i=1}b_i^2\right)&=\color{red}{\sum_{i=1}^na_i^2b_i^2}+\color{blue}{\sum_{1\le i<j\le n}a_i^2b_j^2+\sum_{1\le i<j\le n}a_j^2b_i^2}\\\\ &=\color{red}{\sum_{i=1}^na_i^2b_i^2}+\color{blue}{\sum_{1\le i<j\le n}\left(a_i^2b_j^2+a_j^2b_i^2\right)}\;. \end{align*}

Now try to mimic the rest of the computation in $(1)$ in the general case.

-

Hint:

$$\left(\sum_{i=1}^n a_i^2 \right) \cdot \left(\sum_{j=1}^n b_j^2 \right) = \sum_{\substack{i,j=1 \\i \not= j}}^n a_i^2 \cdot b_j^2 + \sum_{i=1}^n a_i^2 \cdot b_i^2 = \sum_{i<j} a_i^2 \cdot b_j^2 + \sum_{j<i} a_i^2 \cdot b_j^2 + \sum_{i=1}^n a_i^2 \cdot b_i^2 \\ = \sum_{i<j} (a_i^2 \cdot b_j^2 + a_j^2 \cdot b_i^2) + \sum_{i=1}^n a_i^2 \cdot b_i^2$$

Use something similar for the second summand and you obtain the given formula.

-