Is $X - Y(Y^\top Y)^{-1}Y^\top XY(Y^\top Y)^{-1}Y^\top$ positive semi-definite or negative definite? Let $X$ is a positive definite matrix and $Y$ is a matrix of full column rank. Is the following matrix positive semi-definite or indefinite:
$$
X - Y(Y^\top Y)^{-1}Y^\top XY(Y^\top Y)^{-1}Y^\top
$$
I tried to decompose it into a product of $(\cdot)$ and $(\cdot)^\top$, but couldn't.
 A: Let $U$ denote a matrix whose matrix form an orthonormal basis for the column space of $Y$. We have
$$
Y(Y^TY)^{-1}Y^T = UU^T,
$$
so that the matrix under consideration is
$$
M = X - UU^TXUU^T.
$$
Let $V$ denote a matrix whose columns extend the columns of $U$ to an orthonormal basis. Let $W = [U \ \ V]$. We find that $M$ is similar to
$$
W^TMW = \pmatrix{U^T\\ V^T} [X - UU^TXUU^T] \pmatrix{U & V} = 
\pmatrix{0 & U^TXV\\ V^TXU & V^TXV}.
$$
With that, it is easy to see that $M$ will be positive semidefinite if and only if $U^TXV = 0$, which occurs if and only if the column space of $Y$ is an invariant subspace of $X$, which occurs if and only if $XP = PX$, where $P = Y(Y^TY)^{-1}Y^T$.
If $M$ is not positive semidefinite, then it must be indefinite.
A: Suppose $X-PXP\succeq0$ where $P=Y(Y^YY)^{-1}Y^T$ is the orthogonal projection onto $V=\operatorname{range}(Y)$. Then $0\le(v+w)^T(X-PXP)(v+w)=2v^TXw+w^TXw$ for any $v\in V$ and $w\in V^\perp$. Therefore $v^TXw=0$, or else we can scale $w$ down by a (possibly negative) small number $\epsilon$ to make the RHS of the previous inequality negative. It follows that $V$ and $V^\perp$ are invariant subspaces of $X$. Since $P|_V=\operatorname{id}$ and $P|_{V^\perp}=0$, we see that $XP=PX$.
Conversely, if $XP=PX$, then $X-PXP=(I-P)X(I-P)\succeq0$. Therefore $X-PXP\succeq0$ if and only if $XP=PX$.
In case $X-PXP$ is not positive semidefinite, we must have $P\ne I$. Hence there exists some nonzero vector $w\in V^\perp$ and $w^T(X-PXP)w=w^TXw>0$. Therefore $X-PXP$ cannot be negative semidefinite and it must be indefinite.
