relation of R-module homomorphisms with direct sums If $f$ is a module homomorphism from $A$ to $B$ and $g$ is a module homomorphism from $B$ to $A$, and $g \circ f$ is the identity function, why is it that $B= \operatorname{im}(f) + \ker(g)$?
 A: For a $b\in B$ consider the element $x=f (g(b)) -b\in B$. We claim  that this $x$ is in the kernel of $g$.  Then it will  follow that $b=  x+f(g(b))$  where in the rhs first element is in $\ker g$ and the second element is in image of $f$, that is what you wanted to be proved.
To prove the claim apply $f$ to this element $x$ and use  the condition that $g$ is a homomorphism and satisfies $g\big(f(x)\big)=id(x)=x$.
We see that
$g (\, f(g(b) )-b \,) = g(b)-g(b)=0$. So $x=f(g(b))-b\in\ker g$. 
A: For a module such as $B$, with submodules $C$ and $D$, we of course have the submodule $C + D$ of $B$, which is, by definition,
$C + D= \{ c + d \mid c \in C, d \in D \} \subset B; \tag{1}$
in the event that $C \cap D = \{ 0 \}$, the notation $C \oplus D$ may also be used; $C \oplus D$ is then referred to as the direct sum of $C$ and $D$.  We observe that any $y \in C \oplus D$ may be uniquely written $y = c + d$ with $c \in C$, $d \in D$, for if $c_1 + d_1 = c_2 + d_2$, then 
$0 = c_1 - c_2 = d_1 - d_2 \in C \cap D, \tag{2}$
since $C \cap D = \{ 0 \}$; we have $c_1 = c_2$ and $d_1 = d_2$.  On the other hand, if $C \cap D \ne \{ 0 \}$, then if $0 \ne w \in C \cap D$, $c + d = (c + w) + (d - w)$; thus the decomposition of $y = c + d$ is not unique in this case.  So we distinguish between the ordinary submodule sum $C + D$, which may always be formed but does not yield uniqueness, and the direct sum $C \oplus D$, which is only defined when $C \cap D = \{ 0 \}$, but for which the unicity binds.
The title to this question is cast in terms of the direct sum,  but the body of the post only mentions
$B = \operatorname{im}(f) + \ker(g); \tag{3}$
furthermore, both the astute comment of darij grinberg and the clear and concise answer of P Vanchinathan (which I endorsed) only address (3) as is; i.e., neither of them mentions the possibility that we might in fact also have
$\operatorname{im}(f) \cap \ker(g) = \{ 0 \}, \tag{4}$
which together with (3) would then yield
$B = \operatorname{im}(f) \oplus \ker(g), \tag{5}$
as the title inquires.  Perhaps our OP Meelod wrote as he/she did since (3) was the only sticking point experienced, and thus comments and answers focussed on this aspect of the question (perhaps tacitly) indicated in the title, that is, to show the stronger assertion (5) binds.  
Given (3), all we must do to obtain the stonger (5) is prove (4); but this is easy:  suppose
$b \in \operatorname{im}(f) \cap \ker(g); \tag{6}$
then $b = f(a)$ for some $a \in A$, whence
$a = 1_A a = (gf)(a) = g(f(a)) = g(b) = 0, \tag{7}$
also by virtue of (6).  Thus,
$b = f(a) = f(0) = 0, \tag{8}$
so (4) and hence (5) hold under the given hypothesis.  
