A symmetric matrix with eigenvalues all $0$ or all $1$: does it equal $0$ or identity?

I have these general wondering about matrices but I don't know to proceed with a proof or a counter example. Suppose that $A$ (dimension $n\times n$) is a real symmetric matrix.

1. If $A$ has $n$ eigenvalues that are all $1$'s, does $A$ equal the identity matrix?
2. If $A$ has $n$ eigenvalues that are all $0$'s, does $A$ equal the zero matrix?

Can someone elucidate things for me please?

Edit: I learned/can look up diagonalization theorems for real matrices.

• Compute $Av$ for a given $v$ and express $v$ in the eigenbasis. – djechlin Dec 3 '14 at 1:55
• Do you know a theorem about "diagonalizing" a real symmetric matrix? – GEdgar Dec 3 '14 at 1:56
• Let $N=\begin{pmatrix}0&1\\0&0\end{pmatrix}$. Take $1+N$ for the first, and $N$ for the second. – Pedro Tamaroff Dec 3 '14 at 2:05

The answer to both is yes.

Hint: All symmetric matrices are diagonalizable. That is, $A$ is similar to a diagonal matrix with the eigenvalues of $A$ on the diagonal.

A real symmetric matrix is orthogonally diagonalisable.So there exists an orthogonal matrix $P$ such that $P^{-1}AP=D$ where $D$ is a diagonal matrix.Then since $1$ is the only eigen value of $A$ , $0$ is the only eigen value of $A-I$ so $det(A-I)=0$. Again $A=PDP^{-1}$

$\implies det((PDP^{-1})-I)=0$

$\implies det(P(D-I)P^{-1})=0$

$\implies det(D-I)=0$

Since $D$ is a diagonal matrix $D=I$. Consequently $A=PIP^{-1}=I$