I'm completing a homework question and I need to prove the following:
$$ \sum_{i=1}^{N} ||\vec{y} - \vec{x}_{i}||^{2} = \sum_{i=1}^{N} ||\vec{x}_{i} - \vec{\bar{x}}||^{2} + N||\vec{y}-\vec{\bar{x}}||^{2} $$
where $\vec{\bar{x}} = \frac{1}{N} \sum_{i=1}^{N} \vec{x}_{i}$ and $||\cdot||$ is the Euclidean norm and these are all vectors.
I think I probably need to do something similar to the proof for the sample variance but not sure how to modify it when I have a $y$ in now.
\begin{align*} \sum_{i=1}^{N} ||\vec{y} - \vec{x}_{i}||^{2} & = \sum_{i=1}^{N} ||(\vec{y} - \vec{\bar{x}}_{i}) + (\vec{\bar{x}} - \vec{x}_{i})||^{2} \\ & = \sum_{i=1}^{N} ((\vec{y} - \vec{\bar{x}}) + (\vec{\bar{x}} - \vec{x}_{i})) ((\vec{y} - \vec{\bar{x}}) + (\vec{\bar{x}} - \vec{x}_{i}))^{T} \\ & = \sum_{i=1}^{N} (\vec{y} - \vec{\bar{x}})(\vec{y} - \vec{\bar{x}})^{T} + 2 \sum_{i=1}^{N} (\vec{y} - \vec{\bar{x}})(\vec{\bar{x}} - \vec{x}_{i})^{T} + \sum_{i=1}^{N} (\vec{\bar{x}} - \vec{x}_{i})(\vec{\bar{x}} - \vec{x}_{i})^{T} \\ & = \sum_{i=1}^{N} || \vec{\bar{x}} - \vec{x}_{i} ||^{2} + N ||\vec{y} - \vec{\bar{x}}||^{2} \end{align*}
since
\begin{align*} \sum_{i=1}^{N} (\vec{y} - \vec{\bar{x}})(\vec{\bar{x}} - \vec{x}_{i})^{T} & = \sum_{i=1}^{N} \sum_{j} (y_{j} - \bar{x}_{j})(\bar{x}_{j} - x_{ij}) \\ & = \sum_{i=1}^{N} \sum_{j} (y_{j}\bar{x}_{j} - y_{j}x_{ij} - \bar{x}_{j}^{2} + \bar{x}_{j}x_{ij}) \\ & = \sum_{j} \Bigg[ Ny_{j}\bar{x}_{j} - y_{j} \sum_{i=1}^{N}x_{ij} - N\bar{x}_{j}^{2} + \bar{x}_{j}\sum_{i=1}^{N}x_{ij} \Bigg] \\ & = \sum_{j} \Bigg[ Ny_{j}\bar{x}_{j} - y_{j}N\bar{x}_{j} - N \bar{x}_{j}^{2} + \bar{x}_{j}N\bar{x}_{j} \Bigg] \\ & = \sum_{j} 0 \\ & = 0 \end{align*}