Simultaneously diagonalization of two matrices.
If you consider $A,B$ as quadratic forms, then, of course, they are simultaneously diagonalizable. That is, there is an invertible $S$ s.t. $S^TBS=I,S^TAS=D$ where $D$ is a diagonal matrix.
Proof: diagonalize $B$ and $B^{-1/2}AB^{-1/2}$. Since $B^{-1/2}AB^{-1/2}$ is symmetric, there is an orthogonal $O$ s.t. $O^TB^{-1/2}AB^{-1/2}O=D$ where $D$ is diagonal. Finally take $S=B^{-1/2}O$.
Yes, if and only if they have the same eigenvectors.
Equivalently, if and only if they commute.