# Manipulating summations that include the magnitude squared of vectors

I'm really bad with sigma summation notation and have been puzzling over how my professor in his notes for class got from one step to the next.

It's pretty simple:

$$D_{avg} = \sum_{i=1}^n \sum_{x \in C_i} ||\mathbf x-\mathbf m_i||^2$$ $$D_{IC} = \sum_{i=1}^n \frac{1}{|C_i|} \sum_{x \in C_i} \sum_{x' \in C_i}||\mathbf x-\mathbf x'||^2$$

$$m_i = \frac{1}{|C_i|} \sum_{x \in C_i} \mathbf x$$

therefore $$D_{IC} = 2D_{avg}$$

I tried to simply substitute the expression for $m_i$ into $D_{IC}$, but I think I am getting stuck on manipulating $||\mathbf x - \mathbf x'||$ because they're vectors and not scalars.

Here is what I have thus far:

$$D_{IC} = \sum_{i=1}^n \sum_{x' \in C_i}||\mathbf m_i-\mathbf x'||^2$$

Obviously, I know this is wrong..

Hence $$D_{IC} =2D_{avg}$$