Orthogonal diagonalization

In linear algebra, an orthogonal diagonalization of a normal matrix (e.g. a symmetric matrix) is a diagonalization by means of an orthogonal change of coordinates.

The following is an orthogonal diagonalization algorithm that diagonalizes a quadratic form q(x) on $$\mathbb{R}$$n by means of an orthogonal change of coordinates X = PY.

Then X = PY is the required orthogonal change of coordinates, and the diagonal entries of $$P^T A P$$ will be the eigenvalues $$\lambda_1,\dots,\lambda_n$$ which correspond to the columns of P.
 * Step 1: find the symmetric matrix A which represents q and find its characteristic polynomial $$\Delta(t).$$
 * Step 2: find the eigenvalues of A which are the roots of $$\Delta(t)$$.
 * Step 3: for each eigenvalue $$\lambda$$ of A from step 2, find an orthogonal basis of its eigenspace.
 * Step 4: normalize all eigenvectors in step 3 which then form an orthonormal basis of $$\mathbb{R}$$n.
 * Step 5: let P be the matrix whose columns are the normalized eigenvectors in step 4.