A coin is flipped 100 times. Let $X$ be the number of heads in the first 70 flips and $Y$ the number of heads in the last 50. Compute the correlation of $X$ and $Y$.
Here's my attempt: $\rho=\frac{cov(X,Y)}{\sigma_X \sigma_Y}=\frac{E[XY]-E[X]E[Y]}{\sqrt{70(.5)(.5)*50(.5)(.5)}}=\frac{5-35(25)}{\sqrt{218.75}}=\frac{-870}{14.8}=-58.8.$
But that's obviously not right because $0 \le \rho \le 1.$
Where did I go wrong?
Let $U, V, W$ be the number of heads in the first $50$, the next $20$, and the last $30$. Then $X=U+V$ and $Y=V+W$. We have $$E(XY)=E(UV)+E(UW)+E(V^2)+E(VW).$$ Three of the terms are easy to evaluate, using independence. For $E(V^2)$, the easiest way is to use the fact that $\text{Var}(V)=E(V^2)-(E(V))^2$.