# Finding a matrix $P$ such that $P^TAP$ is diagonal

I'm kind of confused on some linear algebra. On a previous question I was given a quadratic form and I had to find a matrix $P$ such that $P^TAP$ is diagonal. I did this by using a suitable change of co-ordinates and letting $P$ be the change of basis matrix and this worked fine.

Now I am given a (symmetric) matrix and I have to find an orthogonal matrix $P$ such that $P^TAP$ is diagonal. In my notes, they work out the eigenvectors and let $P$ be the matrix of eigenvectors. What I want to know is why the same process used for the first matrix doesn't work here?

For example, I have the matrix $\begin{pmatrix}-5 & 12 \\ 12 & 5\end{pmatrix}$. I want to try and find an orthogonal matrix $P$ such that $P^TAP$ is diagonal. I know that I can do this by finding the eigenvectors, but I want to try it using the other method. So I get that this corresponds to the quadratic form $q = -5x^2+24xy+5y^2=-5(x-\frac{12}{5}y)^2-\frac{169}{5}y^2$. Using the change of variable $x'=x-\frac{12}{5}y, y'=y$, I get $q = -5(x')^2-\frac{169}{5}(y')^2$ with change of basis matrix $P = \begin{pmatrix}1 & 0 \\ \frac{-12}{5} & 1\end{pmatrix}$. But this matrix is not orthogonal and does not satisfy $P^TAP$ being a diagonal matrix. Could anyone explain why it doesn't work for this matrix, but does work for one like $q=wz-xy$?

• what you need is not any(invertible) change of coordinates which gives you $P^{-1}AP$ but an orthogonal change of coordinates. so that $P^T = P^{-1}.$
– abel
Nov 5, 2014 at 20:43
• But in both cases, I've only been using a linear change of coordinates. Nov 5, 2014 at 20:44
• @abel Is it always possible to find an orthogonal change of coordinates? If not, is there a quick way to tell which method would be best for finding P? Nov 5, 2014 at 20:50
• It's not clear to me what the difference between the two methods you describe is. The business with eigenvalues and eigenvectors is nothing but a way to find "a suitable change of coordinates". Nov 5, 2014 at 20:57
• @user112495, for symmetric matrices the answer is yes you can always find a an orthogonal set of eigenvectors making up the orthogonal matrix and the diagonals are made up of the eigenvalues. problem arises for non symmetric matrices when they have repeating eigenvalues, e.g, nilpotent matrix [[0 0],[0 1]].
– abel
Nov 5, 2014 at 22:25

i will take your quadratic form $-5x^2 + 24xy + 5y^2$ transform into $ax_1^2 + by_1^2$ with the orthogonal transformation $x = x_1 \cos \theta - \sin \theta y_1, y = x_1\sin \theta + y_1 \cos \theta.$
$-5x^2 + 24 xy + 5y^2 = x_1^2(-5\cos^2 \theta + 24 \sin \theta \cos \theta + 5 \sin^2 \theta) + 2x_1y_1(10 \sin \theta \cos \theta + 12 \cos^2 \theta - 12 \sin^2 \theta) + y_1^2(-5 \sin^2 \theta -24 \sin \theta \cos \theta + 5 \cos^2 \theta).$
now choose $\theta$ so that coefficient of $x_1y_1$ is zero. that is $\tan(2\theta) = {12 \over 5}.$ putting this value of $\theta$ gives you $0 = x_1^2(-5*5 + 12*12) + y_1^2(5*5 - 12*12) = x_1^2 - y_1^2$