I'm taking an online stats class. Currently we are on the topic of a correlation coefficient. Several formulas for $r$ were given in the reading material. The formulas are below. Unfortunately it was not explained how these formulas were derived.
Formula 1:
$$r_{XY}=\frac{\sum{z_X z_Y}}{n-1}$$
Formula 2:
$$r_{XY}=\frac{SP}{(n-1)(s_x)(s_y)},$$
where $SP$ is the sum of products and calculated as
Formula 3: $$SP=\sum{xy} - \frac{\sum{x} \sum{y}}{n}$$
Formula 4: $$r_{XY} = \frac{n \sum{xy} - \sum{x}\sum{y}}{\sqrt{[n\sum{x^2} - (\sum{x})^2]} \sqrt{[n\sum{y^2} - (\sum{y})^2]}}$$
That's a lot of formulas with no explanations.
How is formula 1 derived?
Can someone explain how we arrived to Formula 2 from Formula 1?
How did we arrive to formula 3 from formula 1?
What do $s_x$ and $s_y$ mean in the denominator of formula 2? Nowhere in the previous readings as well as lecture videos it was explained?
Sum of products to me would more look like $SP = \sum{xy}$, so where does $- \frac{(\sum{x}) (\sum{y})}{n}$ in Formula 3 comes from?