TITLE: Diagonalize a symmetric matrix
QUESTION [5 upvotes]: let $$A = \left(\begin{array}{cccc} 1&2&3\\2&3&4\\3&4&5 \end{array}\right)$$
I need to find an invertible matrix $P$ such that $P^tAP$ is a diagonal matrix and it's main diagonal may have only the terms from the set $\{ 1,-1,0 \}$
I'd be glad if you could explain to me how to solve this. I haven't found the right theorem/algorithm.
Thanks.

REPLY [2 votes]: I never remember exactly how this goes, so let's think about it. 
Since $1,-,1,0$ are the eigenvalues of $A$, there exists vectors $v_1,v_2,v_3$ such that
$$
Av_1=v_1,\ \ Av_2=-v_2,\ \ Av_3=0.
$$
Also, the fact that $A$ is symmetric guarantees that 
$$
v_1^tv_2=v_1^tv_3=v_2^tv_3=0.
$$
If we take $P=\begin{bmatrix}v_1&v_2&v_3\end{bmatrix}$, then
$$
AP=\begin{bmatrix}Av_1&Av_2&Av_3\end{bmatrix}=\begin{bmatrix}v_1&-v_2&0\end{bmatrix}
$$
and
$$
P^tAP=\begin{bmatrix}v_1^t\\ v_2^t\\ v_3^t\end{bmatrix}\,\begin{bmatrix}v_1&-v_2&0\end{bmatrix}
=\begin{bmatrix}
v_1^tv_1&-v_1^tv_2&0\\ v_2^tv_1&-v_2^tv_2&0\\ v_3^tv_1&-v_3^tv_2&0
\end{bmatrix}
=\begin{bmatrix}
v_1^tv_1&0&0\\ 0&-v_2^tv_2&0\\ 0&0&0
\end{bmatrix}
$$
So if we take $v_1$ and $v_2$ to be unit vectors, then $P=\begin{bmatrix}v_1&v_2&v_3\end{bmatrix}$ is the matrix you are looking for.