Define $f : \mathbb{R} \to \mathbb{R}$ and $g : \mathbb{R} \to \mathbb{R}$ by $f(x) = x^2 + 1$ and $g(x) = x + 2$. Find $f \circ g$ and $g\circ f$. I understand that $f \circ g$ is $f(g(x))$ and $g \circ f$ is $g(f(x))$ but am not sure where $f : \mathbb{R} \to\mathbb{R}$ and $g : \mathbb{R} \to \mathbb{R}$ is involved or if they are just defining that $f(x)$ and $g(x)$ are in the real number system
(Discrete Mathematics)
They are just defining the functions $f$ and $g$ as maps from the Reals to the Reals. That's all. Take a real number transform it using the rule $f$ and the result is still a real number.
In discrete math, you start to realized that particular functions can have particular mappings. You learn of the domain and range and here, you are defining the function in such a way that you can see what the domain and range are. Depending on the map, it could simply be the codomain instead of the range. In this case the range would be a subset of the codomain. So for example, if you had a function
$$f:\mathbb{R}\rightarrow\mathbb{R}; f(x)=x^2$$
you are mapping real numbers to real numbers. But notice that the image of $f$, does not map to all the reals. Thus the codomain would be $\mathbb{R}$ but the range would be the interval $[0,\infty)$. Thus you wuold have to be careful on which sets your functions are mapping to and from. That makes a big difference.