# What are the conditions for the existence of a special orthogonal similarity transformation?

Suppose we have two $n \times n$ real Gram matrices $X = AA^T$ and $Y = BB^T$. Then, when $diag(\lambda_X) = diag(\lambda_Y)$ (where these are the matrices of eigenvalues), there exists orthogonal $U$ where $X = U Y U^T$, in this special case, because $X$ and $Y$ are diagonalizable, so one can take the product of the diagonal bases.

I'm wondering, what are the conditions on $X$ and $Y$ that make $U \in SO(n)$? This question seeks to answer the general case of symmetric matrices, but its answer doesn't get into specifics. We already know $det(U) = \pm 1$, so what is it about a real Gram matrix that would make its eigendecomposition have $det = -1$?

For reference, I'm interested mostly in applications. Specifically, for a set of Gram matrices $\mathcal{M} = \{ M_1, \dots, M_t \}$ can we determine $\mathcal{U} = \{ U_1, \dots, U_{t-1} \}$ where $M_{i+1} = U_i M_i U_i^T$ and all $U_i \in SO(n)$, possibly subject to some smoothing of the $M_i$. In most applications I'm interested in, we won't have the condition $diag(\lambda_X) = diag(\lambda_Y)$, but any perturbation is in fact measurement noise.

Edit: Some interesting facts can be found in Afriat (1957), doi:10.1017/S0305004100032916 - he explores the concept of canonical bases for pairs of linear subspaces.