You can
put this solution on YOUR website!a) The matrix D is idempotent iff
Since

is the matrix where each diagonal entry is squared, and

and

, this means that EVERY diagonal element will NOT change. So each entry of

is equal to its corresponding entry of
So this means that

and that the matrix D is idempotent.
Unfortunately I can't type out generalized matrices here, but hopefully you can see it.
b)
Let's assume that X is nonsingular (ie X is invertible). So this means that

exists and
So if we want A to be idempotent, then we have to show that
So

since

using the associative property

since

because from part a) we proved that

Using the definition that
So since we've shown that

, this means that matrix A is idempotent.
Hopefully this is clear. If not, let me know.
You can
put this solution on YOUR website!a) A matrix A is idempotent if

. 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

) 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

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

.
b)

, from the condition of (a) above.