# Orthogonal basis for a matrix

I need to find an orthogonal matrix $P$ such that $P^tAP$ is diagonal, where:

$$A=\begin{pmatrix} 1&1&1&1\\ 1&1&1&1\\ 1&1&1&1\\ 1&1&1&1 \end{pmatrix}$$

I know that this matrix $P$ exists because $A^tA=AA^t$ ($A$ is normal).

The characteristic polynomial of $A$ is $p(x)=x^3(x-4)$. The eigenvectors are $v_1=(-1,1,0,0)$, $v_2=(-1,0,1,0)$, $v_3(-1,0,0,1)$ (for $x=0$) and $v_4=(1,1,1,1)$ (for $x=4$).

I know eigenvectors associated with different eigenvalues ​​are orthogonal, but $v_1,v_2,v_3$ are not orthogonal vectors.

I try to find $P$ applying Gram-Schmit procedure with $v_1,v_2,v_3,v_4$ but with this matrix do not hold that $P^tAP$ is diagonal.

Is this idea correct? maybe I'm making a miscalculation to find $P$ or I'm doing something else wrong?

-
Apply G-S to just $v_1$, $v_2$, and $v_3$ ($v_4$ will still be orthogonal to the space spanned by the new vectors). –  David Mitra Dec 12 '12 at 16:01
@DavidMitra, Thanks. But if I applied G-S to all eigenvectors I will not necessarily get a matrix $P$ such that $P^tAP$ is diagonal (I think so), right? –  Hiperion Dec 12 '12 at 16:08
Sorry, $v_4$ is already orthogonal to each of $v_1$, $v_2$, and $v_3$ (as expected); so G-S should work, as indicated in the answer below. Your calculations when performing G-S must have been in error. –  David Mitra Dec 12 '12 at 16:20
I will try to find my error (again). Thanks. –  Hiperion Dec 12 '12 at 16:28

thanks, but why? the eigenvectors "chance the form" when I applied G-S... Then $P^tAP$ is not diagonal... I think so. –  Hiperion Dec 12 '12 at 16:25
But G-S does work and I even checked it just now, but the matrix won't fit in this comment box. The reason it works is that the Gram-Schmidt process doesn't change the span of any initial sequence of the vectors you feed in; moreover,the eigenspaces are orthogonal since $A$ is normal, and orthogonal vectors don't really interact when you Gram-Schmidt them. The upshot is that Gram-Schmidt keeps the eigenspaces invariant, and so it sends eigenvectors to eigenvectors. –  user108903 Dec 12 '12 at 16:46
Keep $v_1$ and $v_4$ and change $v_2, v_3$ until they are all mutually orthogonal eigenvectors. This can all be done with vectors which have entries from $\{-1,0,1\}$, so there are only finitely many possibilities to try.