# Composite Functions

A composite function is formed from two functions in the following way.

$$(g \circ f)(x) = g(f(x))$$
If $f(x)=x+3$ and $g(x)=2x$ are two functions, then we combine the two functions to form the composite function:
\begin{align} (g \circ f)(x) &= g(f(x)) \\ &= 2f(x) \\ &= 2(x+3) \\ &= 2x+6 \end{align}
That is, $f(x)$ replaces $x$ in the function $g(x)$.
The composite function reads $g$ of $f$ and can be written $g \circ f$.

$$(f \circ g)(x) = f(g(x))$$
Another composite function is:
\begin{align} (f \circ g)(x) &= f(g(x)) \\ &= g(x) + 3 \\ &= 2x+3 \end{align}
In this case, $g(x)$ replaces $x$ in $f(x)$. This composite reads $f$ of $g$ and can be written $f \circ g$.

For the composite function $f(g(x))$ to be defined, the range of $g$ must be a subset if (or equal to) the domain of $f$. It is easiest to list the domain and function of both $f(x)$ and $g(x)$ first when dealing with composite function problems.

### Example 1

Given $f(x)=2x-1$ and $g(x)=3x+5$, find the simplest expression of $(f \circ g)(x)$.

### Example 2

Given $f(x)=4x-5$, find the simplest expression of $(f \circ f)(x)$.

### Example 3

Given $f(x)=2x+7$ and $g(x)=-x+2$, find the simplest expression of $(g \circ f)(2)$.

### Example 4

Given $f(x)=\sqrt{x}$ and $g(x)=x+1$, find the domain and range of $(g \circ f)(x)$.

### Example 5

Given $f(x)=-2x+3$, $g(x)=5x+k$ and $(g \circ f)(x)=(f \circ g)(x)$, find $k$. 