I have two concentric circles $C_1$ and $C_2$ with radii $r_1,r_2$ such that $r_1< r_2$and a set of finite points $P=\left \{ p_1,p_2...p_n \right \}$ and $Q=\left \{ q_1,q_2...q_n \right \}$ are identified on circles $C_1,C_2$ respectively.
Now I would like to rotate the circle $C_1$ such that the sum of squares of the Euclidean-distances $\sum_i^nd(p_i,q_i)^2$ is minimized, where $d(.)$ indicates the Euclidean-distance.
Note that both $p_i$ and $q_i$ are 2-d coordinates in real space. What is the angle of optimal rotation, in either a clockwise or anti-clockwise direction that minimizes these sums of Euclidean distances?
I was looking at it as $P$ being hit by a rotation matrix and was finding the gradient w.r.t $\theta$ in the rotation matrix.
Let $p_i=(r_1\cos\phi_i,r_1\sin\phi_i)$ and $q_i=(r_2\cos\theta_i,r_2\sin\theta_i)$. Then rotating by $\psi$ leads to
$$ \begin{align} \sum_{i=1}^nd(p_i,q_i')^2 &= \sum_{i=1}^n\left((r_1\cos(\phi_i+\psi)-r_2\cos\theta_i)^2+(r_1\sin(\phi_i+\psi)-r_2\sin\theta_i)^2\right) \\ &= n(r_1^2+r_2^2)-2r_1r_2\sum_{i=1}^n\cos(\phi_i-\theta_i+\psi) \\ &= n(r_1^2+r_2^2)-2r_1r_2\Re\sum_{i=1}^n\mathrm e^{\phi_i-\theta_i+\psi} \\ &= n(r_1^2+r_2^2)-2r_1r_2\Re\left(\mathrm e^\psi\sum_{i=1}^n\mathrm e^{\phi_i-\theta_i}\right) \;. \end{align} $$
This is minimal for
$$\psi=\arg\left(\sum_{i=1}^n\mathrm e^{\theta_i-\phi_i}\right)\;,$$
and the minimal value is
$$ n(r_1^2+r_2^2)-2r_1r_2\left|\sum_{i=1}^n\mathrm e^{\theta_i-\phi_i}\right| \;. $$