Let $R$ be a ring, $M$ be a finitely generated free $R$-module and $f \in \text{End}_R(M)$. Does the following hold? $$\text{rk}(M)=\text{rk(Ker}(f))+\text{rk(Im}(f)).$$
This is the last question of an exercise whose aim seems to be to show that modules and vector spaces don't always behave the same way (e.g. a submodule of a free module is not necessarily free). Therefore, my guess is that the equality above doesn't always hold, but I am unable to find any counterexample.
Maybe the easiest way would be to find some endomorphism whose kernel and/or image are not free, so that the equation is not even well defined. But I don't even know if this is possible, since maybe the kernel and the image of a finitely generated free module via an endomorphism are always free.
Thanks
I'm not familiar with this kind of thinking, but what about this: let $ R=M=\mathbb Z_4$, and $ f (k)=2k $. Then $\ker f =\text {Im}\, f =\{0,2\}$ is not free.