# If $0 \to M \to N \to S \to 0$ splits, then $N \cong M \oplus S$

I am trying to show that if we have the left splitting short exact sequence of $$R$$-modules $$0 \longrightarrow M \xrightarrow{\enspace f \enspace} N \xrightarrow{\enspace g \enspace} S \rightarrow 0 \,,$$ then there exists an isomorphism of $$R$$-modules $$\phi \colon N \to M \oplus S$$.

I know that there is $$\psi \colon N \to M$$ such that $$\psi \circ f = \mathrm{Id}_M$$, and we have the epimorphism $$g \colon N \to S$$, so maybe the morphism $$\beta \colon N \to M \oplus S$$ defined as $$\beta(n) = (\psi(n), g(n))$$ could work ($$\beta$$ would be $$\phi^{-1}$$).

It is easy to show that $$\beta$$ is a module morphism. I am having some difficulty to prove it is injective and surjective, I would appreciate some help, maybe I’ve chosen the wrong morphism.

For the surjectivity, if you take any $$(m,s)\in M\oplus S$$, take $$f(m)+s'-f\circ\psi(s')$$ where $$s'$$ is any preimage of $$s$$ under $$g$$.
For injectivity, if $$(\psi(n),g(n))=(0,0)$$, then $$n$$ is in the image of $$f$$ because the sequence is exact, i.e., $$n=f(m)$$, but then $$0=\psi (n)=\psi\circ f (m)=m$$ and so $$n=0$$.