= Solution
The <spectral theorem for real symmetric matrices> supplies real <eigenvalues> and an <orthonormal eigenbasis>. Compute <eigenvectors>, normalize them, and within each repeated-eigenvalue <eigenspace> choose an orthonormal basis. Distinct <eigenspaces> are already orthogonal because symmetry gives $(\lambda-\mu)v^Tw=0$ for <eigenvectors> with <eigenvalues> $\lambda,\mu$.
Use the resulting basis <vectors> as columns of $O$. Then
$$
\boxed{O^TO=I,\qquad O^TMO=D=\operatorname{diag}(\lambda_1,\ldots,\lambda_n).}
$$
The order and signs of the columns can be chosen freely; rotations within a repeated-eigenvalue <eigenspace> are also allowed.
Back to article page