'Understanding analogy between correlation formulas in Matlab for correlation coefficient

I'm having a hard time understanding that these formulas for computing the correlation coefficient are identical (let x and y be column vectors):

  1. cov(x,y)/(std(x)*std(y))
  2. ((zscore(x)')*zscore(y))/(length(x)-1)
  3. ((x-mean(x))'*(y-mean(y)))/sqrt(sum((x-mean(x)).^2)*sum((y-mean(y)).^2 ))

Why in (3) we don't divide by N-2 yet the result is correct?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source