Finding eigenvalues of a square matrix
I am asked to find the eigenvalues of the following matrix \begin{align} M = \begin{pmatrix} p & 0 & p \\ 0 & p & p \\ p & p & 2p \\ \end{pmatrix} \end{align}
I know that : \begin{align} Mv &= \lambda v \\ (M - \lambda I_3) v &= 0 \\ |M -\lambda I_3| &= 0 \end{align} So I solve : \begin{align} \begin{vmatrix} p-\lambda & 0 &p \\ 0 & p-\lambda & p \\ p & p & 2p-\lambda \\ \end{vmatrix} = (p-\lambda)^2 (2p-\lambda) = 0 \end{align} Which yields eigenvalues : $\lambda_1 = 2p$ and $\lambda_{2,3} = p$. However this is not correct because using a Solver like WolframAlpha yields eigenvalues $\lambda_1 = 3p$, $\lambda_2 = p$ and $\lambda_3 = 0$. What am I doing wrong ?
N.B : I am asking this question for a homework I am therefore looking for hints rather than full solutions.
EDIT : I just found that the matrix does not have full rank. Which means that one eigenvalue should be 0.
Solution 1:
Actually, we have\begin{align}\begin{vmatrix}p-\lambda&0&p\\0&p-\lambda&p\\p&p&2p-\lambda\end{vmatrix}&=-\lambda ^3-3 \lambda p^2+4 \lambda ^2 p\\&=-\lambda(\lambda-p)(\lambda-3p).\end{align}So, the eigenvalues are $0$, $p$ and $3p$.
Solution 2:
The following doesn't hold:
$$ \begin{vmatrix} p-\lambda & 0 &p \\ 0 & p-\lambda & p \\ p & p & 2p-\lambda \\ \end{vmatrix} = (p-\lambda)^2 (2p-\lambda) $$
We can't just multiply the diagonals.
If we expand along the first row,
$$(p-\lambda) [(p-\lambda) (2p-\lambda)-p^2]-p^2(p-\lambda)=0$$
$$(p-\lambda)[(p-\lambda)(2p-\lambda)-2p^2]=0$$
$$(p-\lambda)[\lambda^2-3\lambda p]=0$$