The rank of a symmetric matrix equals the number of nonzero eigenvalues. I am wondering why 

the rank of a symmetric matrix equals its number of nonzero
  eigenvalues.

I have tried showing it like this:
A symmetrix matrix A can be written:
$$A=PDP^T$$, where P is an orthogonal matrix.
It is not difficult to see that for a vector x: $PDP^Tx=0 \leftrightarrow DP^Tx=0$, 
since P is invertible.
So what we need to show is that dimension of the nullspace of $DP^T$ equals the number of eigenvalues with value zero.
Do you see how to do this?

More precisely, I would say that the rank of a symmetric matrix is equal to the sum of the geometric multiplicities of its nonzero eigenvalues.
For example, If $A$ has two nonzero eigenvalues, say $2$ and $3$, with geometric multiplicities $1$ and $2$ respectively, then the rank of $A$ is $1+2 = 3$.
In this example, $2$ and $3$ would appear once and twice in $D$ respectively. So the number of repetitions of nonzero eigenvalues in $D$ needs to be considered
