Question 376125
a) A matrix A is idempotent if {{{A^2 = A}}}.  Let D = [d(k,j)] be a diagonal nxn matrix Suppose the diagonal entry d(k,k) = 0.  Then the dot product of the kth row of D and the kth column of D (when we're determining {{{D^2}}}) is also 0 (because the rest of the entries in that row and column are zeroes).  
If d(k,k) = 1, then the dot product of the kth row of D and the kth column of D is also 1, (again because the rest of the entries in that row and column are zeroes).  Thus {{{D^2}}} and D have the same diagonal elements.  But the product of any two compatible diagonal matrices is also a diagonal matrix, and thus all the off-diagonal entries are also zero.  Therefore {{{D^2 = D}}}.

b)  {{{A^2 = XDX^(-1)*XDX^(-1) = XDDX^(-1) = XD^2X^(-1) = XDX^(-1) = A}}}, from the condition of (a) above.