Polynomial expansion (plus/minus trick in statistics) Suppose the random variables $X_1, ..., X_n$ are independent and identically distributed. Let $\mu_x$ denote the expected value of $X$, and let $\bar{X} = \frac{1}{n}\sum_{i=1}^n X_i$. I often see the following plus/minus trick used in statistics, i.e.
\begin{align*} \frac{1}{n} \sum_{i=1}^n (X_i - \bar{X})^2 &= \frac{1}{n}\sum_{i=1}^n(X_i - \mu_X + \mu_X - \bar{X})^2 \\
&= \frac{1}{n}\sum_{i=1}^n(X_i - \mu_x)^2 - (\bar{X} - \mu_x)^2\end{align*} 
Can someone formulate this into an identity for me? That is, something like
$(a - b)^2 = (a - c + c - b)^2 = (a - c)^2 + (c - b)^2 + \text{some cross term}?$
What exactly is that cross term? 
On a similar token, I've also seen
\begin{align*} \frac{1}{n} \sum_{i=1}^n (X_i - \bar{X})(Y_i - \bar{Y}) &= \frac{1}{n}\sum_{i=1}^n(X_i - \mu_X )(Y_i - \mu_Y) - (\bar{X} - \mu_x)(\bar{Y} - \mu_Y) \end{align*}
What polynomial expansion identity is at play here?

The cross term is as you would expect from $(x+y)^2=x^2+y^2+2xy$:
\begin{align} 
(a-b)^2 &= ((a-c)+(c-b))^2 \\
&=(a-c)^2 + (c-b)^2 + 2(a-c)(c-b)
\end{align}
So for any constant $\alpha \in \mathbb{R}$ you get 
\begin{align}
\left(X_i-\overline{X}\right)^2 &= \left(X_i-\alpha + \alpha - \overline{X}\right)^2 \\
&= (X_i-\alpha)^2 + \left(\alpha - \overline{X}\right)^2 + 2\left(X_i-\alpha\right)\left(\alpha-\overline{X}\right)
\end{align} 
But since $(\alpha - \overline{X})$ does not depend on $i$, when you sum the last term over $i \in \{1, ..., n\}$ and then divide by $n$, you get 
\begin{align}
\frac{1}{n}\sum_{i=1}^n 2(X_i-\alpha)(\alpha-\overline{X})&= 2(\alpha-\overline{X})\frac{1}{n}\sum_{i=1}^n(X_i-\alpha) \\
&= 2\left(\alpha-\overline{X}\right)\left(\overline{X}-\alpha\right)
\end{align}
Thus, indeed we get: 
$$ \boxed{\frac{1}{n}\sum_{i=1}^n \left(X_i-\overline{X}\right)^2 = \frac{1}{n}\sum_{i=1}^n(X_i-\alpha)^2 - \left(\overline{X}-\alpha\right)^2 \quad \forall \alpha \in \mathbb{R}}$$
Similarly it can be shown
\begin{align}
&\frac{1}{n}\sum_{i=1}^n(X_i-\overline{X})(Y_i-\overline{Y})  \\
&= \frac{1}{n}\sum_{i=1}^n(X_i-\alpha)(Y_i-\beta) - (\overline{X}-\alpha)(\overline{Y}-\beta) \quad \forall \alpha, \beta \in \mathbb{R}
\end{align}

This is similar to the following identities: 
\begin{align}
Var(X) &= Var(X-\alpha) \quad \forall \alpha \in \mathbb{R}\\
Cov(X,Y) &= Cov(X-\alpha, Y-\beta) \quad \forall \alpha, \beta \in \mathbb{R}
\end{align}
where we recall
\begin{align}
Var(X) &= E[(X-E[X])^2] = E[X^2] - E[X]^2\\
Cov(X,Y)&= E[(X-E[X])(Y-E[Y])] = E[XY]-E[X]E[Y]
\end{align}
For example, for all $\alpha \in \mathbb{R}$ we get
\begin{align}
E[(X-E[X])^2] &= Var(X) \\
&= Var(X-\alpha)\\
&= E[(X-\alpha)^2] - (E[X]-\alpha)^2 
\end{align}
