All textbooks and websites I've consulted define function composition thus:
Let $f: A \rightarrow B$ and $g: B\rightarrow C$ be functions. The composite of $f$ and $g$ is the function $f \circ g: A\rightarrow C $ such that $f\circ g(x)=f(g(x))$.
But I have a doubt: since the domain of the composite function is $A$, then for each element of $A$ there must be a corresponding image, i.e., $f(g(x))$ must be defined, but in order for $f(g(x))$ to be defined
- $g(x)$ must exist, which implies that $x$ belongs to the domain of $g$, which is $B$, therefore $\forall x\in A, x\in B$, or $A\subseteq B$
- $f(g(x))$ must exist, which means that $g(x)$ belongs to $A$, the domain of $f$, and therefore $g(x)\in A \forall x\in A$ or, equivalently, $g(A)\in A$; but $g(x)\in C$ as well, therefore $g(A)\in A\cap C$
Did I go wrong somewhere? If not, why aren't these restrictions included in the definition of composite function?
Whatever sources you're looking at are wrong. The composition $$f\circ g$$ represents applying the function $g$ then applying the function $f$. As you notice, for this to work everywhere in the desired domain, we need the domain of $f$ to be (or at least contain) the range of $g$. Thus, the proper definition would have $g:A\rightarrow B$ and $f:B\rightarrow C$ with $f\circ g:A\rightarrow C$.