Given two functions $f(x)$ and $g(x)$, infinitely many compositions can be generated. For example we can look at the following two functions:
$$f(x) = 2x$$
$$g(x) = x+1$$
There is a subspace of all functions that can be generated such as the following examples:
$$(g\circ f)(x) = g(f(x)) = 2x+1$$
$$(g\circ f\circ f)(x) = 4x+1$$
$$(f\circ f\circ f\circ g\circ g\circ f)(x) = 16x+16$$
Is there a way to see if functions fall into this space? For the above example, it is easy to see that any function following
$$h(x) = 2^{c_1}*x+{c_2}$$
can be generated, but a function such as
$$h(x) = x$$
can never be generated from $f(x)$ and $g(x)$. Is there a way to generalize this to any two functions in order to see what functions can/cannot be generated?