How did they simplify normal equations for OLS in linear regression? How did they go from (1) to (2):
\begin{align*}
      S_{xx} &= \sum(X_i - \bar{X})^2 \tag1 \\ 
             &= \sum(X_i - \bar{X}) X_i \tag2 \\
             &= \sum X_i^2 - \left(\sum{X_i}\right)^2/n \\
             &= \sum X_i^2 - n \bar{X}
\end{align*}
In (2), are they simply saying that $(X_i - \bar{X}) = X_i$? Why is that so?
It is also seen here in OLS equation:
$$b_1 = \frac{\sum X_i Y_i - \left[\left(\sum X_i \right) \left(\sum Y_i \right)\right]/n}{\sum X_i^2 - \left( \sum X_i\right)^2 /n} = \frac{ \sum\left(X_i -\bar{X}\right) \left(Y_i - \bar{Y}\right)}{\sum \left(X_i - \bar{X} \right)^2}$$
The technique is used again in the denominator, when they go from middle equation to the right. Why is it?
 A: $$
    \sum (X_i - \bar{X})^2
$$
$$
    \sum(X_i - \bar{X})(X_i - \bar{X})
$$
$$
    \sum (X_i^2 - 2\bar{X}X_i + \bar{X}^2)
$$
$$
    \sum \left[(X_i^2 - \bar{X}X_i) + (\bar{X}^2 - \bar{X}X_i)\right]
$$
$$
    \sum \left[(X_i - \bar{X})X_i + (\bar{X} - X_i)\bar{X}\right]
$$
We can "distribute" the $\Sigma$ over those two summands.  The second one turns out to be zero
$$
    \sum (\bar{X} - X_i)\bar{X}
$$
$$
    \bar{X} \sum (\bar{X} - X_i)
$$
$$
    \bar{X} (\sum \bar{X} - \sum X_i)
$$
$$
    \bar{X} (n\bar{X} - n\bar{X})
$$
$$ 
    0
$$
A: Simple numerical example
Let $X_1 = 1$, $X_2 = 3$, $X_3 = 8$
Then $\bar{X} = \frac{1}{3} \left( 1 + 3 + 8\right)$ = 4
It is not at all correct to say $(X_1 - \bar{X}) = X_1$ which would be equivalent to saying that (1 - 4) = 1
The point is that 
$$ \sum_i \bar{X} \left( X_i - \bar{X} \right) = 0$$
because $\sum_i X_i = n \bar{X}$. In this example $1 + 3 + 8 = 3 \cdot 4 = 12$
In this example, the statement $\sum_i \bar{X} \left( X_i - \bar{X} \right) = 0$ would be:
$$4\left( 1 - 4 \right) + 4 \left( 3 - 4 \right) + 4 \left(8 - 4\right) = 0$$
If you factor our $\bar{X}$:
$$ \bar{X} \left[ \sum_i \left( X_i - \bar{X} \right) \right] = 4 \left[ ( 1 - 4) + (3 - 4) + (8 - 4) \right] = 0$$
