Is the rank of a matrix equal to the number of non-zero eigenvalues? I have studied before that the rank of a matrix = number of non zero Eigen values. But recently i came across a problem and i dont think it is valid there. I know i am going wrong somewhere. 
$$A=
\begin{bmatrix} 
0 & 4 & 0 \\
0 & 0 & 4\\
0 & 0 & 0 \\
\end{bmatrix}
\quad
$$
The Rank of this matrix is 2. So there should be 2 non zero eigen values. But I only get 0 as the eigen value(λ) using $$[A-λI]=0$$ 
Can anybody explain? Thanks
 A: 
rank of a matrix = number of non zero Eigen values

is not true, as you have witnessed.
Consider that $A^3=0$, so if $A$ has an eigenvalue $\lambda$ and $v\neq0$ is a corresponding eigenvector, then
$$
0=A^3v=\lambda^3v
$$
meaning $\lambda^3=0$, so $\lambda$ must be $0$.
The rank is, however, equal to the dimension of the image. Which is to say, the size of the largest possible set of linearly independent vectors of the form $Av$.
It is also the case that nilpotency (or more specifically the fact that the image may contain elements of the kernel) is in some sense the only thing that can go wrong with your statement.
A: Unfortunately, the answer is no in general, though the claim will hold true for diagonalizable matrices. Not all matrices are diagonalizable, including the matrix that you gave in your example. If your matrix is $n \times n$, then diagonalizability is equivalent to having a set of $n$ linearly independent eigenvectors, and those eigenvectors corresponding to non-zero eigenvalues will form a basis for the range of the matrix; hence rank is obtained (including multiplicities).
However, if you look at $A^T A$, then you can use the eigenvalues of that matrix to obtain the rank, regardless of what $A$ is. This is because $A^T A$ is symmetric, and thus must be diagonalizable, and furthermore one can show that $\mathrm{rank}(A^T A) = \mathrm{rank}(A)$.
A: This statement holds true when the Jordan blocks of A associated with eigenvalue 0 are all 1 by 1; Otherwise, there would be extra rank entailed by such Jordan blocks. For example, $rank(J_2(0)) = 1$.
Equivalently you can say the geometric and algebraic multiplicity of eigenvalue 0 agrees with each other.
Or, the minimal polynomial of A is $q_A(t)=t*\Pi_{i=1}^{d-1}(t-\lambda_i)^{r_i}$, where we assumed there are d distinct eigenvalues of A and the maxiaml sizes of their corresponding Jordan blocks are $r_i$.
Note that I took nonzero eigenvalue of algebraic mulitplicty k>1 as k nonzereo eigenvalues instead of 1; Otherwise we would need the equivalence between algebraic and geometric multiplicity of not only zero eigenvalues but also that of the nonzero eigenvalues of A. And therefore the diagonalizability would be necessary.
I could be wrong, feel free to correct me.
