# Compactness of the set of rank K projectors

I hope you could give a hint for proving that the following set is compact $$(k:

$$X=\left\{A\in \mathbb{R}^{n\times n}:A=A^{t},A^{2}=A,rank(A)=k\right\}$$

I can proof that $$X$$ is bounded(not so difficult, to be honest). But to prove that $$X$$ is closed, the rank $$k$$ property stucks me.

Hint: Consider the characteristic polynomial.

More details are hidden below.

A projection has rank $$k$$ iff its characteristic polynomial is $$x^{n-k}(x-1)^k$$ (since it can be diagonalized so its diagonal entries are $$n-k$$ $$0$$s and $$k$$ $$1$$s). The coefficients of the characteristic polynomial are polynomials and hence continuous in the entries of the matrix, so the set of matrices with any given characteristic polynomial is closed.

one approach to show openness of the complement:

0.) Select a norm easy to work with-- I suggest Frobenius norm
1.) The result is immediate for non symmetric matrices
2.) for any matrix $$B$$ in the complementary set, it is symmetric and orthogonally diagonalizable, and the Frobenius Norm is orthogonally invariant in reals, so assume WLOG that your matrix $$B$$ is diagonal with eigenvalues in the usual ordering $$\lambda_1 \geq \lambda_2 \geq .... \geq \lambda_n$$. Now show for any $$B$$, $$\big \Vert B-A\big \Vert_F \geq 0$$

and the inequality is strict unless we select $$A:=B$$ which is allowable iff diagonal matrix $$B$$ has $$k$$ ones and $$n-k$$ zeros on the diagonal, i.e. iff $$B$$ is a rank k projector. When the inequality is strict, then there is some $$\delta \gt 0$$ neighborhood around $$B$$ such that all matrices in this neighborhood are not in the set containing $$A$$, hence the set containing $$B$$'s is open and your set containing $$A$$'s is closed. Put differently the complementary set of symmetric matrices, in effect (up to orthogonal similarity), is the set of all diagonal matrices that aren't purely $$k$$ oness and $$n-k$$ zeros.