Two matrices A and B are called simultaneously diagonalizable by congruence if there exists a non-singular matrix U such that
U^{T}AU and U^{T}BU are diagonal matrices. A known sufficient condition for the simultaneous diagonalization of A and B is that A is symmetric positive semi-definite and B is symmetric. Please note that this notion is different from the (probably better known) simultaneous diagonalization in the sense that U^{-1}AU and U^{-1}BU are diagonal, which becomes
U^{T}AU and U^{T}BU are diagonal with U orthogonal when A and B are symmetric. The necessary and sufficient condition for the latter simultaneous diagonalization is that A and B commute. The sufficient condition above for the simultaneous diagonalization by congruence shows that for this simultaneous diagonalization A and B does not need to commute.
I hope my description above is not too confusing and it is clear what is the difference between the two simultaneous diagonalizations. The answer to my question may be well known from some textbook in Linear Algebra. I would be grateful if you could send me a reference, book or paper, where the necessary and sufficient condition is given.