the difference of idempotent matrices $\newcommand{\rank}{\operatorname{rank}}\newcommand{\diag}{\operatorname{diag}}$Let $A,B$ be two $n\times n$ real matrices with the property ($A^t$ is the transpose of $A$)
$$A^t=A=A^2, B^t=B=B^2.$$
Show that
$$\|(A-B)x\|\leq \|x\|,\forall\ x\neq 0,$$
where $$\|x\|^2=\sum_{i=1}^n |x_i|^2, x=(x_1,\ldots,x_n).$$
Moreover,
$$\|(A-B)x\|<\|x\|,\forall\ x\neq 0$$
if and only if 
$$\rank(A)=\rank(B).$$
What I have done is as follows. Since $A^t=A=A^2$, there exists an orthogonal matrix $O_1$ such that $$A=O_1^t\diag(I_r,0)O_1,$$ similarly, there exists some orthogonal matrix $O_2$ such that $$B=O_2^t\diag(I_s,0)O_2.$$ Here $r=\rank(A)$, $s=\rank(B)$, $I_r$ is the identity matrix.
Thus,
$$\|(A-B)x\|^2=\|(O_1^t\diag(I_r,0)O_1-O_2^t\diag(I_s,0)O_2)x\|^2\\
=\|O_1^t(diag(I_r,0)O-O\diag(I_s,0))O_2x\|^2\quad (O=O_1O_2^t)\\
=\|(\diag(I_r,0)O-O\diag(I_s,0))x\|^2$$
Now, calculate the matrix 
$$(\diag(I_r,0)O-O\diag(I_s,0)$$ by the entries of $O$. In special cases, I use software to see that it is indeed true.
 A: An idempotent and symmetric matrix is called (orthogonal) projector. Projectors have eigenvalues $0$ and/or $1$ since from $A^2=A$, we have $A(I-A)=0$ (that is, $t(1-t)$ "contains" the minimal polynomial of $A$). It follows that $x^TAx\in[0,1]$ for all unit vectors $x$.
Now let $\lambda$ be an eigenvalue of $A-B$ with the unit eigenvector $x$: $(A-B)x=\lambda x$. Hence $\lambda=x^TAx-x^TBx$ and since both terms are between $0$ and $1$, we get $\lambda\in[-1,1]$. Therefore, $\|A-B\|_2=\rho(A-B)\leq 1$ or, equivalently, $\|(A-B)x\|_2\leq\|x\|_2$ for all $x$.

The second statement is not correct (as indicated by the counter-example in the other answer) and should be as follows:

If $\|(A-B)x\|_2<\|x\|_2$ for all $x\neq 0$, then $\mathrm{rank}(A)=\mathrm{rank}(B)$.

With the first statement, the proof of this one is simple and we just have to show that if the ranks differ there's an $x$ giving the norm equality. Assume that $\mathrm{rank}(A)\neq\mathrm{rank}(B)$. Say, $\mathrm{rank}(A)<\mathrm{rank}(B)$. Since $\mathrm{null}(B)=n-\mathrm{rank}(B)$, we have hence
$$
n<\mathrm{rank}(A)+\mathrm{null}(B)
$$
and therefore, $\mathcal{R}(A)\cap\mathcal{N}(B)$ is nontrivial. There is hence a nonzero $x=Ay$  for some $y\neq 0$ (actually, since $A$ is projector, $y=x$) such that $Bx=0$. We have
$$
(A-B)x=Ax=A^2y=Ay=x
$$
and hence $\|(A-B)x\|_2=\|x\|_2$ for some nonzero $x$. The proof is analogous if $\mathrm{rank}(B)<\mathrm{rank}(A)$.
A: The second strict inequality is not true. Take the projection on first and second axis. The rank is 1 and the inequality is large for the vector basis vectors.
