Must $g(x)$ and $f(x)$ be functions for composition function $(g \circ f)(x)$ to exist I understand that for composite function $(g\circ f)(x)$ to exist, range of $f(x)$ must be a subset of domain of $g(x)$. This is so that every output value of $f(x)$ is mapped to one value of $g(x)$.
However, is this on the assumption that both $g(x)$ and $f(x)$ are functions? Must they both be functions? 
Imagine a case where $f(x) = \pm \sqrt{x}$ and $g(x) = x^2$. in this case $g(f(x))$ is a function right? So I suppose we do not need both $g(x)$ and $f(x)$ to be functions? 
So what does "range of $f(x)$ must be a subset of domain of $g(x)$" actually conclude? 
Addon: I've realised that the example I have given, is for the special case when $g$ and $f$ are inverse of one another. so $(g\circ f)(x) = x$. 
My conclusion is that for composite function $(g\circ f)(x)$ to exists, either


*

*$g(x)$ and $f(x)$ has to be functions, or

*$g(x)$ and $f(x)$ are inverse of one another. 


Am I right? Any help is much appreciated! I still need help.
 A: I'd hate to 'post' this as an 'answer' because it's not really an answer per say but something I would've wrote as a comment over an 'answer.' (Because I'm just thinking out loud)
Usually when I see statements of compositions of functions g$\circ$f, they usually start as if g: X $\rightarrow$ Y is surjective and f:Y $\rightarrow$ Z is surjective, then g $\circ$ f: X $\rightarrow$ Z is surjective. It's in an "if-then" form. So consider a statement: If g: X$\rightarrow$ Y is a function and f: Y $\rightarrow$ Z is a function, then the composition g $\circ$f: X $\rightarrow$ Z is a function. Well with logic for the P implies Q table, if P is false, then the statement is true. Hence, if g or f are not functions, then by that, g $\circ$ f would be a function would be a valid/true statement. The contrapositive would also say that if g$\circ$f is not function, then g is not a function or f is not a function-- again just rambling off ideas.
Also, I'd be careful when saying 'inverses.' If a function f:X $\rightarrow$Y has an inverse say f$^{-1}$:Y $\rightarrow$ X, then that implies f$^{-1}$ is a function, but as you mentioned above, the squareroot is not a function. If anything, might be able to consider it as the pullback.
Mind my loose words, I too am trying to be more concise, but I hope my comment gets you thinking.
