My professor recently surprised us with a pop quiz on probability, and I'm struggling to prove a particular identity involving random variables. Suppose we have two independent random variables, $X$ and $Y$, and define another random variable $Z$ as $Z = X - Y$. I am trying to prove the following expression: $$ \operatorname{E} \bigl[ (Z - E[Z]) \bigr]^2 = \operatorname{var}(X) + \operatorname{var}(Y) $$
The presence of the square outside the expected value is confusing me, even though I confirmed with my professor that it should be there. Can someone guide me through this proof? Any help would be greatly appreciated. Thank you!
The square outside is definitely wrong, because $E(Z-E(Z))^2=(E(Z)-E(E(Z))^2=(E(Z)-E(Z))^2=0$ which can only be equal to $Var(X)+Var(Y)$ if both $X$ and $Y$ are almost surely constant. If it is inside, we have \begin{align*}E((Z-E(Z))^2)&=E((X-Y)^2-(E(X-Y))^2)\\ &=E((X-Y)^2)-(E(X-Y))^2\\ &=E(X^2-2XY+Y^2)-(E(X)-E(Y))^2\\ &=E(X^2)-2E(XY)+E(Y^2)-(E(X)^2-2E(X)E(Y)+E(Y)^2)\\ &=Var(X)+Var(Y)-2(E(XY)-E(X)E(Y))\\ &=Var(X)+Var(Y), \end{align*} where the last equality holds because a family of independent random variables is uncorrelated.