$\operatorname{tr}(A^\text{T}A) = \operatorname{tr}(A)$ if $A$ is idempotent. I know that $
\operatorname{tr}(A)=\operatorname{rank}(A)$ if $A$ is idempotent. Now I need to calculate $\operatorname{tr}(A^\text{T}A)$. I have done some simulation which shows $\operatorname{tr}(A^\text{T}A)=\operatorname{tr}(A)$ but I don’t know how to prove it.
Sorry if I’m making a wrong claim.

It doesn't hold. Take eg. the matrix
$$A= \left[\begin{array}{cc} \frac{2}{3} & -\frac{2}{3} \\ -\frac{1}{3} & \frac{1}{3} \end{array} \right].$$
We see that $\operatorname{tr} A = 1,$ but the trace of
$$A^TA = \left[\begin{array}{cc} \frac{2}{3} & -\frac{1}{3} \\ -\frac{2}{3} & \frac{1}{3} \end{array} \right] \left[\begin{array}{cc} \frac{2}{3} & -\frac{2}{3} \\ -\frac{1}{3} & \frac{1}{3} \end{array} \right] =\left[\begin{array}{cc} \frac{5}{9} & -\frac{5}{9} \\ -\frac{5}{9} & \frac{5}{9} \end{array} \right]$$
is $\frac{10}{9}.$
