Let $f(x)=\sqrt{x+1}$ and $g(x)=x^{2}$. We can define a new function $h$ as

\[

h(x)=f(g(x))=f(x^{2})=\sqrt{x^{2}+1}.

\]
That is, to obtain $h(x)$, we substitute $g(x)$ for $x$ in the expression $f(x)$.

To generalize this process suppose $f$ and $g$ are any two given functions. We start with a number $x$ in the domain of $g$ and apply $g$ to it to get $g(x)$, then we apply $f$ to $g(x)$ and thereby obtain the number $f(g(x))$. Obviously this process presupposes that it makes sense to calculate $f$ at the point $g(x)$. In other words, the new function is defined only if $g(x)$ is in the domain of $f$ (otherwise we cannot use $g(x)$ as the input for $f$).

Consecutive application of functions is known as **composition **of functions. The new function that takes $x$ and assigns to it the value $f(g(x))$ is often denoted by $f\circ g$. The symbol $f\circ g$ is read “$f$ circle $g$.” Figure 1(a) shows the composition $f\circ g$ as a machine diagram and Figure 1(b) illustrates it as an arrow diagram.

**(a)**

**(b)**

**composite**function $f\circ g$ is defined by

\[

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

\]

- In set notation, the domain of $f\circ g$ is

\[\bbox[#F2F2F2,5px,border:2px solid black]{Dom(f\circ g)=\{x|\ x\in Dom(g)\text{ and }g(x)\in Dom(f)\}.}\] - Note that the order of composition of two functions matters. In calculating $(f\circ g)(x)$, we first evaluate $g$ at $x$ and then use $g(x)$ as the input to calculate $f$ of the result. But in calculating $(g\circ f)(x)$, we first evaluate $f$ at $x$ and then calculate $g$ at the the point $f(x)$. Therefore, $(f\circ g)(x)$ is often quite different from $(g\circ f)(x)$.

\[

F(x)=\frac{1}{2+x^{2}},

\] is a composition of three functions $F=f\circ g\circ h$, where

\[

h(x)=x^{2},\qquad g(x)=x+2,\qquad f(x)=\frac{1}{x}.

\] Notice that we can compose $f$ and $g$ first then compose $f\circ g$ with $h$ or we can first compose $g$ and $h$ and then compose $f$ and $g\circ h$. In general, composition is

**associative**. That is

\[

f\circ g\circ h=(f\circ g)\circ h=f\circ(g\circ h)

\]