# Linear algebra: diagonalization and eigenvalues

Find a 3x3 nondiagonal matrix whose eigenvalues are $-2,-2,$ and $3$, and associated eignenvectors are $\begin{pmatrix} 1 \\ 0\\1 \end{pmatrix}$ , $\begin{pmatrix} 0 \\ 1 \\1\end{pmatrix}$, and $\begin{pmatrix} 1 \\ 1 \\1\end{pmatrix}$, respectively.

Answer: $\begin{pmatrix} 3&5&-5 \\ 5&3&-5 \\ 5&5&-7\end{pmatrix}$

I keep getting $\begin{pmatrix} 1&3&-3 \\ 5&3&-5 \\ 3&3&-5\end{pmatrix}$, so I am only getting the second row correct. I know that you're supposed to use the formula pA = PD$P^{-1}$. I had $\begin{pmatrix} 1&0&1 \\ 0&1&1 \\ 1&1&1\end{pmatrix}$ as $P$, $\begin{pmatrix} -2&0&0 \\ 0&-2&0 \\ 0&0&3\end{pmatrix}$ as $D$, and $\begin{pmatrix} 1&0&0 \\ -1&0&1 \\ 1&1&-1\end{pmatrix}$ as $P^{-1}$, and found the product to be $\begin{pmatrix} 1&3&-3 \\ 5&3&-5 \\ 3&3&-5\end{pmatrix}$ which is not right. Am I doing something wrong?

-
Your inverse is incorrect...you can check this yourself. –  fretty Jun 24 '12 at 16:29
I checked it more than three times, and the elementary operations for both the inverse and the original matrix appears to be right for me... –  Ashley Jun 24 '12 at 16:34
But clearly those two matrices do NOT multiply to give the identity matrix. For a start the top left entry would be $2$. –  fretty Jun 24 '12 at 16:35
Yeah, that's the problem. I don't get how the inverse is wrong though. I thought I derived it right –  Ashley Jun 24 '12 at 16:36
Oh, I think I got it. Thanks fretty! –  Ashley Jun 24 '12 at 16:39

I think that $$P^{-1}=\begin{pmatrix}0&-1&1\\-1&0&1\\1&1&-1 \end{pmatrix}$$

> with(linalg):P:=matrix(3,3,[1,0,1,0,1,1,1,1,1]);

[1    0    1]
[           ]
P := [0    1    1]
[           ]
[1    1    1]


PP:=evalm(inverse(P));

                          [ 0    -1     1]
[              ]
PP := [-1     0     1]
[              ]
[ 1     1    -1]


DD:=matrix(3,3,[-2,0,0,0,-2,0,0,0,3]);

                          [-2     0    0]
[             ]
DD := [ 0    -2    0]
[             ]
[ 0     0    3]


evalm((P &* DD) &* PP);

                        [3    5    -5]
[            ]
[5    3    -5]
[            ]
[5    5    -7]

-
Thanks a lot Mohamed! –  Ashley Jun 24 '12 at 17:06