Function composition

In the set of the real functions of real variable we can define an operation completely different called function composition.

Let's consider the functions $$f (x) = x + 3$$ and $$g (x)=x^2-1$$, and any real number, for example $$x = 2$$.

We can calculate the image of $$2$$ under $$f$$ and we obtain $$f (2) = 5$$.

Next we can calculate the image of $$5$$ under $$g$$ and obtain $$g (5) = g (f (2)) = 24$$

In general, given two functions $$f$$ and $$g$$, the function that assigns to every $$x$$ the value of $$g (f (x))$$ is called a function composition of f and g and is denoted by $$g\circ f$$ (it is read $$f$$ composed with $$g$$).

Therefore:

$$$(g \circ f) (x) = g (f (x))$$$

The function $$g \circ f$$ is well defined when x belongs to the domain of f and f (x) belongs to the domain of g. Namely $$$Dom( g\circ f)=\{x \in Dom(f) \mid f(x) \in Dom(g) \}=$$$

$$$=Dom(f)-\{x \in \mathbb{R} \mid f(x) \notin Dom(g)\}$$$

Consider the functions $$f (x) = x + 3$$ and $$g (x) =x^2-1$$, compute the functions $$(g \circ f)$$ and $$(f \circ g)$$, and determine its domain.

$$$(g \circ f) (x) = g (f (x)) = g (x + 3) =(x+3)^2-1=$$$

$$$= x^2+6x+9-1=x^2+6x+8$$$

and since $$Dom (f) = Dom (g) =\mathbb{R}$$, we have:

$$$Dom (g \circ f) = \mathbb{R}$$$

$$$(f \circ g) (x) = f (g (x)) = f(x^2-1) = x^2-1+3= x^2+2$$$As in the previous case, $$$Dom (f \circ g) =\mathbb{R}$$$

We observe that we obtain two different functions, that is, the function composition is not commutative.