Spectral theorem for matrices...... From the spectral theorem we know that 
if $A$ is a symmetric matrix then there exists an orthogonal matrix $M$ such that
$A=M^{-1}DM=M^TAM$
My question is: if I have the matrix $A$ how do I find the matrixes $D$ and $M$?
Thanks a lot
 A: If $A$ is symmetric, then $A$ has an orthonormal basis of eigenvectors. The eigenvectors associated with different eigenvalues are automatically orthogonal. But you have to perform Gram-Schmidt on the eigenvectors with the same eigenvalue in order to get an orthonormal basis of the eigenspace. Once you have the orthonormal basis of eigenvectors, you put them into the columns of a matrix $U=[c_1,c_2,c_3,\cdots,c_n]$. Then
\begin{align}
     AU & = [Ac_1,Ac_2,\cdots,Ac_n] \\
        & =[\lambda_1c_1,\lambda_2c_2,\cdots,\lambda_n c_n] \\
        & = [c_1,c_2,\cdots,c_n]\left[\begin{array}{cccc}\lambda_1 & 0 & 0 & \cdots & 0 \\
                  0 & \lambda_2 & 0 & \cdots & 0 \\
                 \vdots & \vdots & \vdots & \ddots & \vdots \\
                  0 & 0 & 0 &\cdots &\lambda_n\end{array}\right] \\
        & = UD
\end{align}
Because $U$ is an orthogonal matrix, then $U^{T}U=UU^{T}=I$ (replace $U^T$ by conjugate transpose if you are working over complex numbers.) Then you get what you want:
$$
               A = UDU^T.
$$
A: Hint:
$D$ ia the diagonal matrix that has as diagonal elements the eigenvalues of $A$ and $M$ is a matrix that has as columns the corresponding eigenvectors.
Do you know how to find these? ( see here)
