# [SOLVED]squaring sums

#### dwsmith

##### Well-known member
$$\left(\sum_{i = 1}^n(x_i - y_i)\right)^2 = \sum_{i = 1}^n(x_i - y_i)^2 + \sum_{1\leq i\leq j\leq n}|x_i - y_i||x_j-y_j|$$
Why is this true?

#### Sudharaka

##### Well-known member
MHB Math Helper
$$\left(\sum_{i = 1}^n(x_i - y_i)\right)^2 = \sum_{i = 1}^n(x_i - y_i)^2 + \sum_{1\leq i{\color{red}<}j\leq n}|x_i - y_i||x_j-y_j|$$
Why is this true?
Hi dwsmith,

I think you will be able prove this by mathematical induction. I further think that in the second summation the inequality should be changed as highlighted (you can verify this by taking $$n=1$$).

Kind Regards,
Sudharaka.

#### Opalg

##### MHB Oldtimer
Staff member
$$\left(\sum_{i = 1}^n(x_i - y_i)\right)^2 = \sum_{i = 1}^n(x_i - y_i)^2 + \sum_{1\leq i\leq j\leq n}|x_i - y_i||x_j-y_j|$$
Why is this true?
Even with the correction suggested by Sudharaka, this formula is not true. To start with, simplify it by writing $z_i = x_i-y_i$. The formula becomes $$\Bigl(\sum_{i = 1}^nz_i\Bigr)^2 = \sum_{i = 1}^nz_i^2 + \sum_{1\leqslant i < j\leqslant n}|z_i||z_j|.$$

Test that formula by putting n=2. It becomes $(z_1+z_{\,2})^2 = z_1^2 + z_{\,2}^2 + |z_1||z_{\,2}|$. Compare that with the correct formula $(z_1+z_{\,2})^2 = z_1^2 + z_{\,2}^2 + 2z_1z_{\,2}$ and you see that two things are wrong: there is a missing 2, and the absolute value signs should not be there.

#### Sudharaka

##### Well-known member
MHB Math Helper
Even with the correction suggested by Sudharaka, this formula is not true. To start with, simplify it by writing $z_i = x_i-y_i$. The formula becomes $$\Bigl(\sum_{i = 1}^nz_i\Bigr)^2 = \sum_{i = 1}^nz_i^2 + \sum_{1\leqslant i < j\leqslant n}|z_i||z_j|.$$

Test that formula by putting n=2. It becomes $(z_1+z_{\,2})^2 = z_1^2 + z_{\,2}^2 + |z_1||z_{\,2}|$. Compare that with the correct formula $(z_1+z_{\,2})^2 = z_1^2 + z_{\,2}^2 + 2z_1z_{\,2}$ and you see that two things are wrong: there is a missing 2, and the absolute value signs should not be there.
$\left(\sum_{i = 1}^nz_i\right)^2=\sum_{i=1}^{n}z_i^2 + \sum_{i\neq j}z_{i}z_{j}$
$\left(\sum_{i = 1}^n(x_{i}-y_{i})\right)^2=\sum_{i=1}^{n}(x_{i}-y_{i})^2 + \sum_{i\neq j}(x_{i}-y_{i})(x_{j}-y_{j})$