How to simplify OLS formulas? Let $\lbrace x_i,y_i\rbrace_{i=1}^n$ be a random sample.  I am trying to simplify the following expression 
$$\frac{\sum_{i=1}^n x_i y_i - n \bar{X}\bar{Y}}{\sum_{i=1}^n x_i^2 -n\bar{X}^2}$$
to show it equals $$\frac{S_{xy}}{S_x^2}$$
I've been manipulating this for almost 2 hours and haven't made any progress. 
How can I simplify the first expression to yield the second? 

Hint. Observe that
$$
\frac{\sum_{i=1}^n x_i y_i - n \bar{x}\bar{y}}{\sum_{i=1}^n x_i^2 -n\bar{x}^2}
=\frac{\frac1n\sum_{i=1}^n x_i y_i - \bar{x}\bar{y}}{\frac1n\sum_{i=1}^n x_i^2 -\bar{x}^2}\tag1 $$ then we are left with proving that
$$
S_x^2=\frac1n\sum_{i=1}^n \left(x_i -\bar{x}\right)^2=\frac1n\sum_{i=1}^n x_i^2 -\bar{x}^2 \tag2
$$ and that
$$
S_{xy}=\frac1n\sum_{i=1}^n \left(x_i -\bar{x}\right)\left(y_i -\bar{y}\right)=\frac1n\sum_{i=1}^n x_iy_i -\bar{x}\bar{y}. \tag3
$$ 
Let's see how to prove $(2)$. We have
$$
\begin{align}
\frac1n\sum_{i=1}^n \left(x_i -\bar{x}\right)^2&=\frac1n\sum_{i=1}^n \left(x^2_i -2x_i\bar{x}+\bar{x}^2\right)
\\\\&=\frac1n\sum_{i=1}^n x^2_i -2\bar{x}\frac1n\sum_{i=1}^nx_i+\frac1n\sum_{i=1}^n\bar{x}^2
\\\\&=\frac1n\sum_{i=1}^n x^2_i -2\:\bar{x}\times \bar{x}+\frac1n \times n\:\bar{x}^2
\\\\&=\frac1n\sum_{i=1}^n x^2_i -\bar{x}^2.
\end{align}
$$ Similarly one gets $(3)$.
Thus, from $(1)$ we obtain
$$
\frac{\sum_{i=1}^n x_i y_i - n \bar{x}\bar{y}}{\sum_{i=1}^n x_i^2 -n\bar{x}^2}
=\frac{\frac1n\sum_{i=1}^n x_i y_i - \bar{x}\bar{y}}{\frac1n\sum_{i=1}^n x_i^2 -\bar{x}^2}=\frac{\frac1n\sum_{i=1}^n \left(x_i -\bar{x}\right)\left(y_i -\bar{y}\right)}{\frac1n\sum_{i=1}^n \left(x_i -\bar{x}\right)^2}=\frac{S_{xy}}{S_x^2}.\tag4
$$
