Solve $\mathbf{R}\mathbf{A}\mathbf{R}^\top = \mathbf{B}$ for a rotation matrix $\mathbf{R}$ Suppose $\mathbf{R}$ is a $2 \times 2$ rotation matrix, $\mathbf{A}$ and $\mathbf{B}$ are diagonal matrices with positive entries. Can I find a rotation matrix that satisfies the following equality:
$$ 
\mathbf{R}\mathbf{A}\mathbf{R}^\top = \mathbf{B}
$$
My observations

*

*The $2 \times 2$ rotation matrix can be written in terms of the angle $\theta$. If so, there will be only one parameter that we need to estimate but there are four equations to satisfy.


*$\mathbf{R}\mathbf{A}\mathbf{R}^\top$ appears to be the eigenvalue decomposition of a square symmetric matrix. If so, unless $\mathbf{A} = \mathbf{B}$ can we find a solution, which is again gives $\mathbf{R} = \mathbf{I}$ .
 A: A base change will leave eigenvalues invariant. Thus $A$ and $B$ must have the same eigenvalues (thus the same elements in the diagonal, just maybe in a different order).
But then we can assume that $R$ switches coordinates in some way so that each $e_i$ maps into $\pm e_j$ so that $A_{i,i}=B_{j,j}$ (more correctly, it has to map eigenspaces to eigenspaces, but in case that all eigenvalues are distinct this is equivalent and if not we find a $R$ that satisfies the former condition).
Such a matrix is either a rotation or a reflection, determined by the determinant. Now how do be determine this? Suppose the diagonal entries are all distinct. Then there is a unique permutation $\pi$ on $\{1,\ldots,n\}$ so that $A_{i,i}=B_{\pi(i),\pi(i)}$.
$R$ can be given by $e_i=e_{\pi(i)}$ and the determinant of $R=R_\pi$ is given by the parity of $\pi$, so if $\pi$ consists of an even number of transpositions it is a rotation, else it is a reflection.
If it is a rotation, we’re done. If it isn’t, we can replace $R$ by $RS_{i}$ where $S_i$ is the identity with $-1$ in the $i$-th position. This does not change the result, but changes the determinant.
Now if two diagonal values are the same there are multiple possible such permutations, as if $A_{i,i}=B_{j,j}$ then we can simply multiply the permutation with the transposition $(i,j)$ to receive a new valid permutation. Note that this changes the parity of the permutation, thus it would be possible to get an even permutation $\pi$ and thus a rotation $R_\pi$ that solves your equation.
EDIT: For the eigenspaces part: Let $x$ be in the eigenspace of $B$ for eigenvalue $\lambda$. Let $R^Tx = y+r$ with $y$ in the $\lambda$-eigenspace of $A$ and $r$ othogonal to the eigenspace.
Then $AR^Tx = \lambda y + r'=\lambda y + \lambda r + (r'-\lambda r)$ for some $r'=Ar$.
But then
$$ \lambda x = Bx = RAR^Tx = \lambda A(y+r) + A(r'-\lambda r)=\lambda x + A(r'-\lambda r)$$
This implies $\lambda r = r' = Ar$. But as $r$ is orthogonal to the $\lambda$-eigenspace this implies $r=0$.
