question in linear algebra Assume A,B are both matrixs of size of nxn, AB=BA=0, r(A)=r(A^2), then show.that r(A+B)=r(A)+r(B).
I am thinking as following:

But i have difficultes to going on, please help me.
Thanks advance!
 A: Because $r(A) = r(A^2)$, we can deduce that (with an appropriate change of basis) $A$ has the form
$$
A  = \pmatrix{A' &0\\0&0}
$$
where $A'$ is square and invertible with size $r(A)$.  Now, break $B$ down in the same way.  That is,
$$
B = \pmatrix{B_{11}&B_{12}\\B_{21}&B_{22}}
$$
Since $AB = BA = 0$, we can deduce that $B_{11} = B_{12} = B_{21} = 0$.  In particular, we have
$$
B = \pmatrix{0&0\\0&B'}
$$
with the matrices written in this form, the rest is clear.
A: Your idea is good, but it's simpler using directly $A+B$.
Note that $r(A^2)=r(A)$ implies $C(A^2)=C(A)$ and so also $N(A^2)=N(A)$ (column space and null space).
If $x$ is an $n$-dimensional column vector, then
$$
r(A+B)=n-\dim N(A+B)
$$
Suppose $Ax+Bx=0$; then also $A^2x+ABx=0$, so $A^2x=0$. Therefore $Ax=0$ and so also $Bx=0$. Therefore $N(A+B)\subseteq N(A)\cap N(B)$. The other inclusion is clear.
By Grassmann’s formula,
\begin{align}
\dim(N(A)\cap N(B))
&=\dim N(A)+\dim N(B)-\dim(N(A)+N(B))\\
&=n-r(A)+n-r(B)-\dim(N(A)+N(B))
\end{align}
Therefore
$$
r(A+B)=
n-\dim(N(A)\cap N(B))=r(A)+r(B)+\dim(N(A)+N(B))-n
$$
We so need to show that $\dim(N(A)+N(B))=n$. Take an $n$-dimensional vector $z$. Then $Az=A^2z'$ for some $z'$; thus
$$
z=(z-Az')+Az'
$$
Note that $A(z-Az')=Az-A^2z'=0$; also $BAz'=0$, so
$$
z\in N(A)+N(B)
$$
A: More abstract, but essentially the same as the above answer: $r(A)=r(A^2)$ implies $\ker A\cap\operatorname{im} A=\{0\}$, hence $\mathbb R^n=\ker A\oplus\operatorname{im} A$. $AB=BA=0$ implies $\operatorname{im}A\subset\ker B,\operatorname{im}B\subset\ker A$. So $\operatorname{im}A\cap\operatorname{im}B=\{0\}$, and $r(A)+r(B)=\dim(\operatorname{im}A\oplus\operatorname{im}B)$. We now need to prove $\operatorname{im}(A+B)=\operatorname{im}A\oplus\operatorname{im}B$.  
To begin with, we note that $(x+\ker A)\cap\operatorname{im}A$ is non-empty for any $x$. In fact, write $x=u+v$, where $u\in\ker A$ and $v\in\operatorname{im}A$. Then we have $v=x-u\in x+\ker A$, hence $v$ is in $(x+\ker A)\cap\operatorname{im}A$.  
Given $v,w$, let $s\in(v-w+\ker A)\cap\operatorname{im}A$. Then $As=A(v-w)$ and $Bs=0$ (recall that $\operatorname{im}A\subset\ker B$). Consequently $Av+Bw=A(s+w)+B(s+w)\in\operatorname{im}(A+B)$. Done.
