I need certainties. Consider two functions $f: A \to B$ and $g: C \to D$. For what I am going to ask, it's not a loss of generality if we consider multivariable functions with domains and or codomains as subsets (proper or not) of $\mathbb{R}^n$. In any case let's remain vague.
Now my "problem" is to fully understand, once for all, the conditions for which the composition $f\circ g$ (or equivalently, with the obvious variations, $g\circ f$) do exist.
What I understood so far while studying
Given the functions above, let's say we want to compute $f\circ g$.Well in order for this to exist I understood that we have to have $g(C) \subseteq A$, and since we always have $g(C) \subseteq D$ we hence say equivalently $D \subseteq A$.
The details I am missing
Assuming it's ok so far, here is what I am missing:
Is it necessary or sufficient to have $g(C) \subseteq A$?
Is in general (and, if yes, why) $D \subseteq A$ actually a strict equality, that is $D = A$?
I'm asking these questions because after having read some answers over here I am a bit confused.
Domain and Codomain
After this, reading the wikipedia page made me even more confused because I thought that then the composition $f\circ g$ would be $f\circ g: g(C) \to A$ where instead by reading the article I interpreted it is $f\circ g: C \to B$.
My head is hurting.
Of course once understood this I will be able to paraphrase all this to $g\circ f$.
Thank you so much.