Is there a faster way to do this? Find an orthogonal matrix $P$ and a diagonal matrix $D$ such that $A=PDP^T$ Let $A$=\begin{pmatrix}
0 & 1 & 1\\ 
1 & 0 & 1\\ 
1 & 1 & 0
\end{pmatrix}
Find an orthogonal matrix $P$ and a diagonal matrix $D$ such that $A=PDP^T$. (Hint: The eigenvalues of $A$ are all integers.


I managed to do this by finding the eigenvalues through solving the characteristic equation, and then finding the corresponding eigenspace. After that I went ahead to use the Grand-Schdmit process, and got an orthnormal basis. 
My solution was mighty complicated, involving 1.5 pages of workings.


Is there a faster way to do this? Question is worth 5 marks. 
 A: Denote by $B$ the matrix
$$ B = A + I = \begin{pmatrix} 
1 & 1 & 1\\ 
1 & 1 & 1\\ 
1 & 1 & 1
\end{pmatrix}. $$
If you manage to diagonalize orthogonally $B$, then $PBP^T = D$ for some diagonal $D$ and then $PAP^T = D - I$ where $D - I$ is also diagonal. The eigenvalues of $B$ are $3, 0, 0$ which is best seen by writing directly the eigenvalue equation $(B - \lambda I)(x,y,z)^T = 0$:
$$ (1 - \lambda)x + y + z = 0, \\
x + (1 - \lambda)y + z = 0, \\
x + y + (1 - \lambda)z = 0. $$
Adding the three equations you get:
$$ (3 - \lambda)(x + y + z) = 0. $$
So either $\lambda = 3$, and for which the corresponding eigenvector is $(1,1,1)^T$ or $x + y + z = 0$, for which the corresponding eigenvalue is $0$ (with multiplicity two). The eigenvalues of $A$ will be $2, -1, -1$, find an orthogonal basis for $x + y + z = 0$, and you're done. 
A: Using the Gram-Schmidt process, even if you spell it correctly, is not a great idea for this kind of question, as it will in general spoil the hard-earned property of being a basis of eigenvectors. Here is an opportunistic approach that works for this particular matrix $A$.
On thing that is easy to note is that $A+I$ has all entries $1$, so that not only its determinant is $0$, but its rank is only $1$:
$$
  A+I=\begin{pmatrix}1\\1\\1\end{pmatrix}\cdot\begin{pmatrix}1&1&1\end{pmatrix}
$$
Thus the eigenspace for $\lambda=-1$  is the $2$-dimensional kernel of the right matrix $(1~~1~~1)$, the plane given by the equation $x+y+z=0$. Since the trace of $A$ is the sum of its eigenvalues (taken with multiplicities), and it is $0$, the remaining eigenvalue is $2$, and an eigenvector for it is $(1~~1~~1)^T$, which is orthogonal (as it should be given that $A$ is symmetric) to the other eigenspace $x+y+z=0$.
Now to find $P$ we need an orthogonal basis of the eigenspace $x+y+z=0$, and then normalise all those eigenvectors. I can't see any particularly nice orthogonal pairs in that eigenspace, so I'll just take the first vector that comes to mind $(1~~-1~~0)^T$ and take the cross product with the eigenvector $(1~~1~~1)^T$ for $\lambda=2$, to give $(-1~~-1~~2)^T$. Dividing by the norms of these vectors I find
$$
P=\frac1{\sqrt6}
  \begin{pmatrix}\sqrt3&-1&\sqrt2\\-\sqrt3&-1&\sqrt2\\0&2&\sqrt2\end{pmatrix}
\qquad \text{and}\qquad
D=\begin{pmatrix}-1&0&0\\0&-1&0\\0&0&2\end{pmatrix}.
$$
A: I suppose you have managed to show that the eigenvalues of $A$ are $\{2,-1,-1\}$ and the only eigenvector (up to scalar multiple) for $\lambda=2$ is $v=(1,1,1)^T$. The problem now is to find $P$ easily.
Note that for a real symmetric matrix, eigenvectors for different eigenvalues are orthogonal to each other. Therefore, if we can find an orthogonal matrix $P$ whose first column is parallel to $v$, then the other two columns will automatically become eigenvectors for $\lambda=-1$. Now, to find such a matrix $P$, we can use Householder reflection. The relevant formula is
$$P = I - \frac{2uu^T}{\|u\|^2},\ \textrm{ where } u=v-\|v\|(1,0,0)^T.$$
Put $v=(1,1,1)^T$, we get
$$
P = \frac1{\sqrt{3}}\begin{pmatrix}
1 & 1 & 1\\
1 & {\small\frac{\sqrt{3}-1}{2}} & {\small\frac{-\sqrt{3}-1}{2}}\\
1 & {\small\frac{-\sqrt{3}-1}{2}} & {\small\frac{\sqrt{3}-1}{2}}
\end{pmatrix}.
$$
You may verify that $P$ is indeed an orthogonal matrix (i.e. $P^TP=I$) and $A=P\,\ \mathrm{diag}(2,-1,-1)\ P^T$.
