Sum of commuting matrices with rank conditions Let $K$ be a field, and let $A,B\in M(n,K)$ be two matrices such that $AB=BA$ and $rk(A)+rk(B)=rk(A+B).$ I want to prove that
$$Im(A+B)=Im(A)\oplus Im(B).$$
My attempt: clearly we have the containment $Im(A+B)\subseteq Im(A)+Im(B).$ Next, using the hypothesis and Grassmann formula
\begin{equation}
\begin{split}
\dim(Im(A+B))=rk(A+B)=rk(A)+rk(B)&=\dim(Im(A))+\dim(Im(B))\\
&=\dim(Im(A)+Im(B))-\dim(Im(A)\cap Im(B))
\end{split}
\end{equation}
To conclude it then suffices to prove the other containment or that the images of $A$ and $B$ intersect trivially. I tried the two paths, but I don't see how to conclude in both of them. I don't see how to use the property of commutativity of $A$ and $B.$
For instance, if we want to prove that $Im(A)+Im(B)$ by symmetry we only have to prove that $Im(A)\subseteq Im(A+B):$ given $v\in K^n$ we have to find $w\in K^n$ such that
$$Aw+Bw=Av$$
which becomes $$A(v-w)=Bw$$
A posteriori, since the two images must intersect trivially, I should have $w\in \ker(B)$ and $v-w\in \ker(A).$ Using commutativity I also get $Aw\in \ker(B)$ and $B(v-w)\in \ker(A)$ but how can I find this $w$?
Maybe a more abstract path is better, any hint?
 A: As you have noted, we clearly have $\operatorname{Im}(A + B) \subseteq \operatorname{Im}(A) + \operatorname{Im}(B)$. With the fact that $\operatorname{rank}(A + B) = \operatorname{rank}(A) + \operatorname{rank}(B)$, we can see that
$$
\begin{align}
\operatorname{rank}(A) + \operatorname{rank}(B) 
& = \operatorname{rank}(A + B)
\\ &= 
\dim \operatorname{Im}(A + B) 
\\ & \leq \dim[\operatorname{Im}(A) + \operatorname{Im}(B)]
\\ & \leq \dim[\operatorname{Im}(A)] + \dim[\operatorname{Im}(B)] = \operatorname{rank}(A) + \operatorname{rank}(B).
\end{align}
$$
That is, we have $\operatorname{Im}(A + B) \subseteq \operatorname{Im}(A) + \operatorname{Im}(B)$ and $\dim \operatorname{Im}(A + B) = \dim [\operatorname{Im}(A) + \operatorname{Im}(B)]$. Thus, we have $\operatorname{Im}(A + B) = \operatorname{Im}(A) + \operatorname{Im}(B)$.
From there, we need to show that $\operatorname{Im}(A) \cap \operatorname{Im}(B) = \{0\}$. However, as you noted, this follows from the Grassmann formula.
Thus, we conclude that $\operatorname{Im}(A + B) = \operatorname{Im}(A) \oplus \operatorname{Im}(B)$, which is what we wanted.
