Show that $P^{t}AP$ and $P^{t}BP$ are diagonal matrices Suppose $A$ and $B$ are symmetric matrices of the same order. If $AB=BA$, Show that $$P^{t}AP$$ and $$P^{t}BP$$ are diagonal matrices. 
Since $A$ is symmetric, A is diagonalizable. Moreover there exists an orthonormal matrix $T$ such that $T^{t}AT=D$, where $D$ is a diagonal matrix. Let $T^{t}BT=C$. Then $AB=TDT^{t}TCT^{t}=TDCT^{t}$ ALso $BA=TCT^{t}TDT^{t}=TCDT^{t}$. But $AB=BA$ gives $DC=CD$. 
How do I proceed from here??
Thanks for the help!!
 A: What you have to be able to do is find an orthonormal basis $\{ e_{1},e_{2},\cdots,e_{n}\}$ whose elements are eigenvectors of both $A$ and $B$, knowing that each one separately has such a basis, and assuming $A$, $B$ commute with each other. Once you have found such a basis, then you put all of the column vectors $e_{j}$ into the columns of a matrix $P$. It then follows that $P^{t}P=I$ is an orthogonal matrix, and $AP=PD_{A}$ where $D_{A}$ is a diagonal matrix, and $BP=PD_{B}$ where $D_{B}$ is a diagonal matrix. And that gives you what you want. The trick is to find a basis $\{ e_{1},e_{2},\cdots,e_{n}\}$ consisting of eigenvectors of both $A$ and $B$. We know there's a basis of each one separately because $A$ and $B$ are symmetric.
To do this, suppose that $\lambda$ is an eigenvalue of $A$. Then $A=\lambda I$ on the null space $\mathcal{N}(A-\lambda I)$ consisting of all eigenvectors of $A$ with eigenvalue $\lambda$. And this subspace is invariant under $B$; to see why, suppose $Ax=\lambda x$ and notice that $BAx = \lambda(Bx)$, which gives $A(Bx)=\lambda(Bx)$. It could be $Bx=0$, but if it is not, then $Bx$ is also an eigenvector of $A$. So $B$ maps $\mathcal{N}(A-\lambda I)$ back to itself. That means $B$ can be diagonalized on $\mathcal{N}(A-\lambda I)$ with an orthonormal basis $\{ e_{\lambda,1},e_{\lambda,2},\cdots,e_{\lambda,k_{\lambda}}\}$. These vectors are automatically eigenvectors of $A$ with eigenvalue $\lambda$, and they are eigenvectors of $B$ as well. Do this for each eigenvalue $\lambda$ of $A$ and you end up a full basis of eigenvectors of both $A$ and $B$ because we know that set of all eigenvectors of $A$ spans the full space.
