Given two bodies moving along a line, I can find the velocity of the center of mass frame. Taking the time derivative of the Galilean transformation I get
$v'=v-v_{cm}$
By definition, the total momentum of the center of mass frame is $0$. From this, I can then find the velocity of the center of mass frame.
$$\begin{align*} 0 &= \sum m_iv'\\ &= \sum m_i(v_i-v_{cm}) \\ &= \sum (m_iv_i-m_iv_{cm}) \\ &= \sum (m_iv_i)-v_{cm}\sum m_i \\ v_{cm} &= \frac{\sum m_iv_i}{\sum m_i} \end{align*}$$
Now, I am now trying to find the relationship between the total kinetic energy of the particles in the original frame given by $T$ and the total kinetic energy in the center of mass frame $T_{cm}$. The original kinetic energy is
$$T = \sum\frac{1}{2}m_iv_i^2$$
and I believe the kinetic energy in the center of mass frame is given by
$$\begin{align*} T_{cm} &= \sum\frac{1}{2}m_i(v_i-v_{cm})^2\\ &= \sum\frac{1}{2}m_i(v_i^2-2v_iv_{cm}+v_{cm}^2)\\ &= \sum\frac{1}{2}m_iv_i^2 - \sum m_iv_iv_{cm} + \sum\frac{1}{2}m_iv_{cm}^2 \end{align*}$$
and substituting back in (and rearranging) gives
$$T = T_{cm} + \sum m_iv_iv_{cm} - \sum\frac{1}{2}m_iv_{cm}^2$$
However, this does not match the correct solution of
$$T = T_{cm} + \sum\frac{1}{2}m_iv_{cm}^2$$
I believe I am conceptually missing something when I am setting up the total kinetic energy in the center of mass frame, but I can't figure it out for the life of me. Does anybody have a hint as to what I am doing incorrectly?