I've been working on a problem, and it's quite lengthy, so I'm going to restrict the problem while not losing too much information.
I'm given a table of the discrete random variables $X$ and $Y$. I'm asked to find the variance of $Y-X$. The solution breaks down each possible case of $Y-X$ and provides the probability of it. Then it found the expected value of $Y-X$. Neither were a problem for me. However, when attempting to find the variance, the solution simply gave a long sum of numbers. I tried to generalize it (hopefully without any mistakes) and obtained this: $$ \text{Var}(Y-X) = \sum_{w \in W}\text{P}(W=w)\cdot[w - \text{E}(W)]^2, \text{ where } W = Y-X \tag{1} $$ Again, I haven't seen this before. I am however, familiar with $$ \text{Var}(aX+bY) = a^2\text{Var}(X) + b^2\text{Var}(Y) + 2ab\cdot\text{Cov}(X,Y). $$ Are the two somehow equivalent? If not, where does $(1)$ come from?