I'm trying to understand the derivation of the iterative closest point algorithm based on this paper. The expansion of (24.14) to (24.15) is giving me trouble.
I'm wondering how we go from
$$\sum_{i = 1}^n ||Ra_i' - b_i'||^2$$
to
$$\sum_{i = 1}^n||a_i'||^2 - 2tr(R\sum_{i = 1}^na_i'b_i'^T) + \sum_{i = 1}^n||b_i'||^2$$
For context: $a_i'$ and $b_i'$ are $n \times 1$ vectors and $R$ is an $n \times n$ rotation matrix.
I managed to get this far:
\begin{align} \sum_{i = 1}^n ||Ra_i' - b_i'||^2 \\ &= \sum_{i = 1}^n (Ra_i' - b_i')^T(Ra_i' - b_i') \\ &= \sum_{i = 1}^n(a'^T_iR^T - b_i'^T)(Ra_i' - b_i') \\ &= \sum_{i = 1}^na'^TR^TRa'_i - a_i'^TR^Tb_i' - b_i'^TRa_i' + b_i'^Tb'i\\ &= \sum_{i = 1}^n||a_i||^2 - \sum_{i = 1}^n[a_i'^TR^Tb_i' + b_i'^TRa_i'] + \sum_{i = 1}^n||b_i||^2 \end{align}
but then I'm not sure how to factor in the trace. I assume we're using the fact that $tr(A^TB) = tr(B^TA)$ and it's written as $tr(AB^T)$ in the equation I've referenced, which is also equivalent [I'm taking $A = Ra_i'$ and $B = b_i'$].
The trace is cyclic so $\mathrm{tr}(ABC)=\mathrm{tr}(BCA)=\mathrm{tr}(CAB)$, for any matrix $A$, $B$, and $C$ (as long as dimensions are compatible).
https://en.wikipedia.org/wiki/Trace_(linear_algebra)#Cyclic_property
In your situation, when you develop the norm, you get the factor $(b'_i)^T Ra'_i$, which we can rewrite as a trace: $\mathrm{tr}((b'_i)^T Ra'_i)=\mathrm{tr}(R a'_i (b'_i)^T)$
EDIT: The terms ${a'_i}^TR^Tb'_i$ and ${b'_i}^TRa'_i$ are actually the same as they are $1\times1$ matrices. Taking the transpose doesn't change the value. Taking the trace also doesn't change their value. Once we have taken the trace, we can do a cyclic permutation and find the result.