Orthogonal diagonalization

In linear algebra, an orthogonal diagonalization of 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 R"n" by means of an orthogonal change of coordinates "X" = "PY".
The X=PY is the required orthogonal change of coordinates, and the diagonal entries of formula_4 will be the eigenvalues formula_5 which correspond to the columns of P.