# Calculate covariance and correlation

$$X$$ is to $$Ber(1/2)$$ and $$Y$$ is to $$N(0,1)$$. Assume $$X$$ is indep to $$Y$$.

We define $$Z=X+Y, W=X-Y$$. Find $$Cov(Z,W)$$ and $$Corr(Z,W)$$.

Firstly, we know some information:

$$E(X)=1/2, E(Y)=0$$

$$Var(X)=1/4, Var(Y)=1$$

$$E(Z) = E(X+Y)=E(X)+E(Y)=1/2$$

$$E(W)=E(X-Y)=E(X)-E(Y)=1/2$$

Then, $$Cov(Z,W)=E(ZW)-E(Z)E(W)=E(ZW)-(1/2)(1/2)=E(ZW)-1/4$$

$$E(ZW)=E([X+Y][X-Y])=E(X^2-Y^2)=E(X^2)-E(Y^2)$$

We can use variances here to help us.

$$Var(X)=E(X^2)-(E(X))^2=E(X^2)-(1/2)^2=1/4$$

Therefore, $$E(X^2)=1/4+(1/2)^2=1/2$$

Similarly, $$Var(Y)=1=E(Y^2)-(E(Y))^2=E(Y^2)-0$$

Therefore, $$E(Y^2)=1$$

Then, $$E(ZW)=E(X^2)-E(Y^2)=1/2-1=-1/2$$, and $$Cov(Z,W)=-1/2-1/4=-3/4$$

But my textbook says it is $$-1/2$$.

Have I done a step wrong?

The book is wrong. It contains an error in its calculation of $$\mathsf{Cov}(ZW)$$.
\begin{align}\mathsf {Cov}(ZW)&=\mathsf E(X^2)-\mathsf E(Y^2)-\mathsf E(X)\mathsf E(W)\\ &= \tfrac 12-1-(\tfrac 12)\require{cancel}\color{red}{\cancelto{\tfrac 12}{\color{black}{(0)}}}\end{align}
So, therefore the correct answer is indeed: $$\mathsf {Cov}(ZW) =-\tfrac 34$$.
To check: Covariance is Bilinear.\begin{align}\mathsf{Cov}(Z,W)&=\mathsf {Cov}(X+Y,X-Y)\\&=\mathsf{Cov}(X,X)+\mathsf{Cov}(X,-Y)+\mathsf{Cov}(Y,X)+\mathsf{Cov}(Y,-Y)\\ &= \mathsf{Var}(X)-\mathsf{Var}(Y)\\&=\tfrac 14-1\\&=-\tfrac 34\end{align}