Can you diagonalize the matrix $\mathrm P$? Let be $P\in\mathbb{C}^{n\times n}$ so that $P^2=P$. The question is, when is $P$ diagonalizable? I got that the eigenvalues of $P$ can either be 0 or 1 and if there exists a diagonal matrix $D$ so that $D=S^{-1}PS$ then you get $D^2=D$. But I really don't know what to do from there on.
 A: Every matrix satisfying $P^2 = P$ is diagonalizable.
Note that a matrix $P$ is diagonalizable if and only if every vector can be written as a linear combination of $P$'s eigenvectors.  Our matrix $P$ is diagaonlizable because every $x$ can be written in the form
$$
x = (x - Px) + Px
$$
and both $(x - Px)$ and $Px$ are necessarily either the zero vector or eigenvectors of $P$.
A: Hint: A linear operator $ A $ over a finite dimensional vector space $ V $ is diagonalizable if and only if its minimal polynomial splits as the product of distinct linear factors.
Here is a proof sketch for the sake of completion: Let the minimal polynomial $ f(T) $ be a product of distinct linear factors, as $ f(T) = \prod_i (x - \lambda_i) $. Define $ h_i(T) = f(T)/(x - \lambda_i) $, then the ideal generated by the $ h_i(T) $ in the polynomial ring above the ground field is the entire ring, hence we may pick polynomials $ k_i(T) $ such that
$$ \sum_i k_i(T) h_i(T) = 1 $$
Note that substituting $ A $ for $ T $ gives
$$ \sum_i k_i(A) h_i(A) = I $$
Let $ v \in V $ be any vector, and right multiply both sides by $ v $ to obtain
$$ \sum_i k_i(A) h_i(A) v = v $$
Now, note that $ (A - \lambda_i I) k_i(A) h_i(A) v = f(A) k_i(A) v = 0 $, so $ k_i(A) h_i(A) v \in V_{\lambda_i} $. Since $ v $ was arbitrary, we conclude that any vector can be written as the linear combination of the eigenvectors of $ A $, and the result follows. The converse direction is obvious.
A: Since the minimal polynomial $x^2-x$ has all distinct roots, there are no eigenvalues with algebraic and geometric multiplicities different.  The matrix is diagonalizable.  A basis in which it is diagonal will consist of a basis of the null space of $P$ and a basis of the null space of $I-P$.
