I have three equations that seem consistent at the abstract level, but when I implement them I am getting mistakes when there are degenerate eigenvalues. They are
$$A = Q D Q^T$$ $$B = (Q^{-1})^T D Q^{-1}$$ $$AB = Q D^2 Q^{-1}$$
where $A$, $B$, are real symmetric matrices. Notice that $Q$ is a the matrix whose columns are the eigenvectors of $AB$. On the surface these look okay. Clearly multiplying $A$ and $B$ gives $AB$.
Since $A$, $B$ are normal matrices, they should admit a decomposition $A = U \tilde{D} U^T$ for a orthogonal matrix $U$. $Q$ is not an orthogonal matrix. If it was, then that would imply that $AB$ is normal, which it is not in general. Equivalently, it would imply $A=B$ which again is not true in general.
I thought that if $A$ could be diagonalized via $Q D Q^T$, then it was unique up to permutation of diagonal entries and multiplication of the columns of $Q$. But it seems that $ U \tilde{D} U^T$ would also diagonalize $A$. Can I relate $Q$ to $U$ somehow? $U$ is special since $U^{-1} = U^T$, but $Q^{-1} \neq Q^T$, how can they possibly be related?
How can these equations be consistent? And are there certain problems when where are degenerate eigenvalues?