Consider the matrix
$$A = \begin{bmatrix} 1 & 0 & 1 \\ 0 & 2 & k \\ 0 & 0 & 2 \\ \end{bmatrix}$$ where $k$ is a real number.
The characteristic polynomial of $A$ is $(λ −1)(λ−2)^2$. Find the value of $k$ for which the matrix $A$ is diagonalizable and write down a matrix $P$ which diagonalizes $A$ for this value of $k$.
I have attempted the problem by trying to find eigenspaces and hence the basis, to get the matrix $P$. Tried row reducing and other things, but can't seem to get anywhere. I feel like there is a theorem which relates the characteristic polynomial and diagonalizable matrix, but I'm not sure. Any help would be greatly appreciated!
Right, we can read off the characteristic polynomial from the diagonal: $$p(\lambda) = (\lambda-1)(\lambda-2)^2.$$Call the matrix $A$. If the matrix is to be diagonalizable, we must obtain a basis of eigenvectors. We need three vectors. In other words, since $$\dim(\ker(A-{\rm Id})) \geq 1, \quad \dim(\ker(A-2\,{\rm Id})) \geq 1,$$ and $1$ is a simple root of $p(\lambda)$, we have $\dim(\ker(A-{\rm Id}))=1$. So $\dim(\ker(A-2\,{\rm Id}))$ had better be $2$. $$A-2\,{\rm Id } = \begin{bmatrix} -1 & 0 & 1 \\ 0 & 0 & k \\ 0 & 0 & 0 \\ \end{bmatrix}$$ From this it is clear that we get what we want for $k=0$.