If $f$ or $g$ is not well defined, then it may happen that $f*g$ is well defined and not equal to the map $x \ \to\ f(g(x))$ but equal to the map induced by the values $f(g(gen))$ where $gen$ is a generator for $M$. Here is an example of this fact for rings.
i1 : R = QQ[x]
o1 = R
o1 : PolynomialRing
|
i2 : S = R/(x*x)
o2 = S
o2 : QuotientRing
|
i3 : f = map(R,S)
o3 = map (R, S, {x})
o3 : RingMap R <--- S
|
i4 : g = map(S,R)
o4 = map (S, R, {x})
o4 : RingMap S <--- R
|
i5 : h = f*g
o5 = map (R, R, {x})
o5 : RingMap R <--- R
|
i6 : isWellDefined f
o6 = false
|
i7 : isWellDefined h
o7 = true
|
i8 : use R
o8 = R
o8 : PolynomialRing
|
i9 : h(x*x)
2
o9 = x
o9 : R
|
i10 : f(g(x*x))
o10 = 0
o10 : R
|