# $\sum^6_{i=1}(x_i-\bar{x})^2$ as $\sum^6_{i=1}x_i^2 - 6\bar{x}^2$ what rules where applied?

consider the set $X = \{20, 30, 40, 50, 60, 70\}$ and the mean $\bar{x} = 45$ then $\sum^6_{i=1}(x_i-\bar{x})^2 = 1750 = \sum^6_{i=1}x_i^2 - 6\bar{x}^2$.

1. How would I transform the first term by hand to the second. What are the exact steps?
2. Does this transformation always lead to the same result?
• any explicit relationship between $a$ and all the $x_i$? – Taylor Jun 1 '15 at 16:23
• Isn't the first sum 2350 and the second sum 3250? – Barry Jun 1 '15 at 16:24
• @Barry Yep. There must be a typo: the $80$ should be actually a $70$. – Crostul Jun 1 '15 at 16:25
• The identity is not correct. – Mark Viola Jun 1 '15 at 16:39

When $a$ is the average of the $x_i$, you have $$\begin{split} \sum_{i=1}^n (x_i - a)^2 &= \sum (x_i^2 -2ax_i + a^2) \\ &= \sum x_i^2 - 2a \sum x_i + a^2 n \\ &= \sum x_i^2 - 2a (na)+ a^2 n \\ &= \sum x_i^2 - 2n a^2 + a^2 n \\ &= \sum x_i^2 - a^2 n \end{split}$$

• How do you $\sum x_i = na$? Ah okay yes it is derived from the average. – bodokaiser Jun 1 '15 at 16:34

We can derive what $a$ is based on the equality:

$$\sum_i(x_i-a)^2=\sum_i x_i^2 - na^2$$ $$\sum_i((x_i-a)^2-x_i^2)= - na^2$$ $$\sum_i{-2x_ia + a^2}= -na^2$$ $$na^2 - 2a\sum_ix = -na^2$$ $$2na^2=2a\sum_ix$$

So either $a=0$ or $a=\frac{\sum{x}}{n} = \bar{x}$.

If $x_6=70$, then the sum $\sum_{i=1}^{6}x_i=270=6a$. So, $a$ is the average of the $x_i$'s.

Then noting that $(x_i-a)^2=x_i^2-2ax_i+a^2$, we have

$$\sum_{i=1}^{6}(x_i-a)^2=\sum_{i=1}^{6}x_i^2-2a\sum_{i=1}^{6}x_i+6a^2.$$

But, recalling that $a$ is the average of the $x_i$'s, we have $-2a\sum_{i=1}^{6}x_i=-12a^2$. And thus we have the desired result

$$\sum_{i=1}^{6}(x_i-a)^2=\sum_{i=1}^{6}x_i^2-6a^2$$