Mapping composition I have difficulties with this task:
Prove, that every mapping can be written as a composition of surjective and injective mapping.
So for example: $f \circ g = h$;
$f$ is surjective;
$g$ is injective;
$h$ represents every mapping.
Additional task is whether changing the order of mappings ($g \circ f$)  still became a mapping.
The thing i can prove and might be connected with the toppic is, that if $f\circ g =\text{identity}$, then $f$ is injective and $g$ is surjective.
Thank you very much!
 A: You can always write a map $h:X\to Y$ as the concatenation of


*

*the restriction $h|_{\mathrm{im}(h)}:X\to\mathrm{im}(h)$ (which is surjective), and

*the embedding $\iota:\mathrm{im}(h)\to Y$ (which is injective).


Here $\mathrm{im}(h)=\{h(x)\mid x\in X\}\subseteq Y$ denotes the image of $h$. It is not hard to see why $\iota\circ h|_{\mathrm{im}(h)}=h$ holds. 

The other way around is possible too. Let $h:X\to Y$ and define $M:=X\,\dot\cup\, Y$. Then define maps $g:X\to M$ and $f:M\to Y$ via
$$g(x)=x,\qquad f(x)=\begin{cases}
h(x)&\text{for } x\in X\\
x&\text{for } x\in Y
\end{cases}.$$
Then $h=f\circ g$ with injective $g$ and surjective $f$.
A: Let's say $f:A\to B$ and $g:B\to C$ are mappings. Then the product or composition is a mapping $gf: A\to C$ with $gf(a) = g(f(a))$. In general, you can't reverse the order, because $g$ operates from $B$ to $C$, but the domain of $f$ is $A$, so $fg$ isn't even defined.
If we have a mapping $f:A\to B$, we want to show that there exist injective function $h$ and surjective function $g$ such that either $f = hg$ or $f = gh$.
Denote the set
$$f(A) = \{f(a) : a\in A\} $$
If we let $g :A\to f(A)\subseteq B$ be defined such that for every $a\in A$ $g(a) = f(a)$, then it is clear $g$ is surjective. Now we automatically obtain an injective function $h:f(A)\to B$ (how?)
