Functions can be added, subtracted, multiplied and divided creating new functions and graphs that are complicated combinations of the various original functions. One important way to transform functions is through function composition. Function composition allows you to line up two or more functions that act on an input in tandem.

Is function composition essentially the same as multiplying the two functions together?

### Composition of Functions

A common way to describe functions is a mapping from the domain space to the range space:

**Function composition** means that you have two or more functions and the range of the first function becomes the domain of the second function.

There are two notations used to describe function composition. In each case the order of the functions matters because arithmetically the outcomes will be different. Squaring a number and then doubling the result will be different from doubling a number and then squaring the result. In the diagram above, \begin{align*}f(x)\end{align*} occurs first and \begin{align*}g(x)\end{align*} occurs second. This can be written as:

\begin{align*}g \big( f(x) \big)\end{align*} or \begin{align*}(g \circ f) (x)\end{align*}

You should read this “\begin{align*}g\end{align*} of \begin{align*}f\end{align*} of \begin{align*}x\end{align*}.” In both cases notice that the \begin{align*}f\end{align*} is closer to the \begin{align*}x\end{align*} and operates on the \begin{align*}x\end{align*} values first.

**Examples**

**Example 1**

Earlier, you were asked if function composition is the same as multiplying two functions together. Function composition is not the same as multiplying two functions together. With function composition there is an outside function and an inside function. Suppose the two functions were doubling and squaring. It is clear just by looking at the example input of the number 5 that 50 (squaring then doubling) is different from 100 (doubling then squaring). Both 50 and 100 are examples of function composition, while 250 (five doubled multiplied by five squared) is an example of the product of two separate functions happening simultaneously.

**For the next two examples, use the functions below:**

\begin{align*}f(x) = x^2 - 1 \end{align*}

\begin{align*}h(x) = \frac{x - 1}{x + 5}\end{align*}

\begin{align*}g(x) = 3e^x - x\end{align*}

\begin{align*}j(x) = \sqrt{x + 1}\end{align*}

#### Example 3

Show \begin{align*}f \big( h(x) \big) \neq h \big( f(x) \big)\end{align*}

**\begin{align*}f \big( h(x) \big) = f \left( \frac{x - 1}{x + 5} \right) = \left( \frac{x - 1}{x + 5} \right)^2 - 1\end{align*}**

**\begin{align*}h \big( f(x) \big) = h(x^2 - 1) = \frac{(x^2 - 1) - 1}{(x^2 - 1) + 5} = \frac{x^2 - 2}{x^2 + 4}\end{align*}**

In order to truly show they are not equal it is best to find a specific counter example of a number where they differ. Sometimes algebraic expressions may look different, but are actually the same. You should notice that \begin{align*}f \big( h(x) \big)\end{align*}is undefined when \begin{align*}x = -5\end{align*} because then there would be zero in the denominator. \begin{align*}h \big( f(x) \big)\end{align*} on the other hand is defined at \begin{align*}x = -5\end{align*}. Since the two function compositions differ, you can conclude:

\begin{align*}f \big( h(x) \big) \neq h \big( f(x) \big)\end{align*}

#### Example 4

What is \begin{align*}f \Big( j \big( h \big( g ( x ) \big) \big) \Big) \end{align*}?

These functions are *nested* within the arguments of the other functions. Sometimes functions simplify significantly when composed together, as \begin{align*}f\end{align*} and \begin{align*}j\end{align*} do in this case. It makes sense to evaluate those two functions first together and keep them on the outside of the argument.

\begin{align*}f(x) = x^2 - 1; h(x) = \frac{x - 1}{x + 5}; g(x) = 3e^x -x; j(x) = \sqrt{x + 1}\end{align*}

\begin{align*}f \big( j(y) \big) = f \left ( \sqrt{y + 1} \right ) = \left ( \sqrt{y + 1} \right ) ^2 - 1 = y + 1 - 1 = y\end{align*}

Notice how the composition of \begin{align*}f\end{align*} and \begin{align*}j\end{align*} produced just the argument itself?

Thus,

\begin{align*}f \Big( j \big( h \big( g(x) \big) \big) \Big) = h \big( g(x) \big) & = h(3e^x - x) \\ & = \frac{(3e^x - x) - 1}{(3e^x - x) + 5} \\ & = \frac{3e^x - x - 1}{3e^x - x + 5}\end{align*}

**For the next two examples, use the graphs shown below:**

\begin{align*}f(x) = | x |\end{align*}

\begin{align*}g(x)=e^x\end{align*}

\begin{align*}h(x) = -x\end{align*}

#### Example 4

Compose \begin{align*}g \big( f(x) \big)\end{align*} and graph the result. Describe the transformation.

\begin{align*}g(f(x)) = g (|x|) = e^{|x|}\end{align*}

The positive portion of the exponential graph has been mirrored over the \begin{align*}y\end{align*} axis and the negative portion of the exponential graph has been entirely truncated.

#### Example 5

Compose \begin{align*}h \big( g(x) \big)\end{align*} and graph the result. Describe the transformation.

\begin{align*}h \big( g(x) \big) = h(e^x) = -e^x\end{align*}

The exponential graph has been reflected over the \begin{align*}x\end{align*}-axis.

### Review

For questions 1-9, use the following three functions: \begin{align*}f(x) = |x|, h(x) = -x, g(x) = (x - 2)^2 -3\end{align*}.

1. Graph \begin{align*}f(x), h(x)\end{align*} and \begin{align*}g(x)\end{align*}.

2. Find \begin{align*}f \big( g(x) \big)\end{align*} algebraically.

3. Graph \begin{align*}f \big( g(x) \big)\end{align*} and describe the transformation.

4. Find \begin{align*}g \big( f(x) \big)\end{align*} algebraically.

5. Graph \begin{align*}g \big( f(x) \big) \end{align*} and describe the transformation.

6. Find \begin{align*}h \big( g(x) \big)\end{align*} algebraically.

7. Graph \begin{align*}h \big( g(x) \big)\end{align*} and describe the transformation.

8. Find \begin{align*}g \big( h(x) \big)\end{align*} algebraically.

9. Graph \begin{align*}g \big( h(x) \big)\end{align*} and describe the transformation.

For 10-16, use the following three functions: \begin{align*}j(x) = x^2, k(x) = |x|, m(x) = \sqrt{x}\end{align*}.

10. Graph \begin{align*}j(x), k(x)\end{align*} and \begin{align*}m(x)\end{align*}.

11. Find \begin{align*}j \big( k(x) \big)\end{align*} algebraically.

12. Graph \begin{align*}j \big( k(x) \big)\end{align*} and describe the transformation.

13. Find \begin{align*}k \big( m(x) \big)\end{align*} algebraically.

14. Graph \begin{align*}k \big( m(x) \big)\end{align*} and describe the transformation.

15. Find \begin{align*}m \big( k(x) \big)\end{align*} algebraically.

16. Graph \begin{align*}m \big( k(x) \big)\end{align*} and describe the transformation.

### Review (Answers)

To see the Review answers, open this PDF file and look for section 1.11.