Variance and expectation of coin tosses A coin is tossed $n$ times and $x$ is the number of times heads occurs. $\operatorname{v}(X)=2$. What is the co-variance between the no. of heads and tails?
My try: $E(X)=\frac{n}{2}$, $E(X^2)=2+\frac{n^2}{4}$
$\operatorname{cov}(x,y)=E(XY)-E(X)E(Y)=2$
Not sure about the solution. Help needed.
 A: We cannot assume that the coin is fair. For if it is, then $\text{Var}(X)=\frac{n^2}{4}$. And there is no integer $n$ such that $\frac{n^2}{4}=2$.
We will do the calculation in three different ways, with the third way being the simplest.
First way: Let $p$ be the probability of head. Then $E(X^2)=\text{Var(X)}+(np)^2=2+n^2p^2$.
We have $E(X)=np$. If $Y$ is the number of tails, then $E(Y)=n(1-p)$.
Note that $Y=n-X$. So $E(XY)=E(nX-X^2)=n^2 p -(2+n^2p^2)$.
So $E(XY)-E(X)E(Y)=(n^2p-2-n^2p^2)-(np)(n(1-p))=-2$. 
Second way:  Note as above that if $Y$ is the number of tails, then $Y=n-X$.
Thus 
$$E(XY)=E(X(n-X))=nE(X)-E(X^2).$$
Also, 
$$E(X)E(Y)=E(X)(n-E(X))=nE(X)-(E(X))^2.$$
Subtract. There is nice cancellation, and we get
$$E(XY)-E(X)E(Y)=(E(X))^2-E(X^2)=-\text{Var}(X)=-2.$$ 
Third way: Use the fact that $\text{Var}(U+V)=\text{Var}(U)+\text{Var}(V)+2\text{Cov}(U,V)$. 
We have $n=X+Y$. But $\text{Var}(n)=0$, since $n$ is constant. Thus
$$0=\text{Var}(X+Y)=\text{Var}(X)+\text{Var}(Y)+2\text{Cov}(X,Y).$$
But $\text{Var}(Y)=\text{Var}(X)$, so we conclude that $\text{Cov}(X,Y)=-\text{Var}(X)$.
