Let $M$ be a real square matrix such that $M^3 = M$. Prove that $M$ is diagonalizable.
Proof:
We have a $M$, a $2\times2$ matrix, $M$ is diagonalizable if $M$ has 2 linearly independent eigenvectors ${v_1,v_2}$, if so, then: $D = P^{-1}MP$ We give a concrete example:
Let $$ M = \begin{bmatrix}1&3\\2&2\end{bmatrix} $$ then the eigenvalues $x_1 =-1$ and $x_2 = 4$ with eigenvectors $(3,-2)$ and $(1,1)$, respectively.
Hence, $$ P = \begin{bmatrix}3&1\\-2&1\end{bmatrix}, D = \begin{bmatrix}-1&0\\0&4\end{bmatrix} $$
This is my proof but I am not sure about the given condition in the statement $M^3 = M$, how can I use it?