---
# System prepended metadata

title: 2.3 - Composition of functions
tags: ['2.3']

---

[TOC]

# 2.3 - Composition of functions

- Given $f(x)$ and $g(x)$, we invent a new function $f \circ g$:

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

- Easy way to remember: Read it from right to left. Plug $g$ into $f$.

## Composition

### Example. $f(x)=2x+1$, $g(x)=x^2$


### 1. 
\begin{align}
(f \circ g)(1) &=f(g(1)) \\
&=f(1^2) \\
&=f(1) \\
&=2(1)+1 \\
&=3
\end{align}

### 2.
\begin{align}
(f \circ g)(2) &=f(g(2)) \\
&=f(2^2) \\
&=f(4) \\
&=2(4)+1 \\
&=9
\end{align}

### 3.
\begin{align}
f\left(g\left(\frac{1}{2}\right)\right)=&=f\left(\left(\dfrac{1}{2}\right)^2\right) \\
&=f\left(\dfrac{1}{4}\right) \\
&=2 \left(\frac{1}{4}\right)+1 \\
&=\dfrac{2}{4}+1 \\
&=\dfrac{1}{2}+1 \\
&=\dfrac{1}{2}+\dfrac{2}{2} \\
&=\dfrac{3}{2}
\end{align}

### 4. 
\begin{align}
(f \circ g)(x)&=f(g(x)) \\
&=f(x^2) \\
&=2(x^2)+1 \\
&=2x^2+1
\end{align}

- We can also do $g\circ f$: $(g\circ f)(x)=g(f(x))$

### 5.
\begin{align}
(g\circ f)(2)&=g(f(2)) \\ &=g(2(2)+1) \\
&=g(5) \\
&=5^2 \\
&=25
\end{align}

### 6.
\begin{align}
(g \circ f)(-1) &= g(f(-1)) \\
&= g(2(-1) + 1) \\
&= g(-2 + 1) \\
&= g(-1) \\
&= (-1)^2 \\
&= 1
\end{align}

### 7. 
\begin{align}
(g \circ f)\left(\frac{1}{2}\right) &= g\left(f\left(\frac{1}{2}\right)\right) \\
&= g\left(2\left(\frac{1}{2}\right) + 1\right) \\
&= g\left(1 + 1\right) \\
&= g(2) \\
&= 2^2 \\
&= 4
\end{align}

### 8.
\begin{align}
(g \circ f)(x) &= g(f(x)) \\
&= g(2x + 1) \\
&= (2x + 1)^2 \\
&= 4x^2 + 4x + 1
\end{align}

- We can also do $f\circ f$ and $g\circ g$:

### 9. 
\begin{align}
(g \circ g)(-2) &= g(g(-2)) \\
&= g((-2)^2) \\
&= g(4) \\
&= 4^2 \\
&= 16
\end{align}

### 10.
\begin{align}
(g \circ g)\left(\frac{1}{2}\right) &= g\left(g\left(\frac{1}{2}\right)\right) \\
&= g\left(\left(\frac{1}{2}\right)^2\right) \\
&= g\left(\frac{1}{4}\right) \\
&= \left(\frac{1}{4}\right)^2 \\
&= \frac{1}{16}
\end{align}

### 11.
\begin{align}
(g \circ g)(x) &= g(g(x)) \\
&= g(x^2) \\
&= (x^2)^2 \\
&= x^4
\end{align}

### 12. 
\begin{align}
(f \circ f)(-1) &= f(f(-1)) \\
&= f(2(-1) + 1) \\
&= f(-2 + 1) \\
&= f(-1) \\
&= 2(-1) + 1 \\
&= -2 + 1 \\
&= -1
\end{align}

### 13.
\begin{align}
(f \circ f)\left(\frac{1}{2}\right) &= f\left(f\left(\frac{1}{2}\right)\right) \\
&= f\left(2\left(\frac{1}{2}\right) + 1\right) \\
&= f(1 + 1) \\
&= f(2) \\
&= 2(2) + 1 \\
&= 4 + 1 \\
&= 5
\end{align}

### 14. 
\begin{align}
(f \circ f)(x) &= f(f(x)) \\
&= f(2x + 1) \\
&= 2(2x + 1) + 1 \\
&= 4x + 2 + 1 \\
&= 4x + 3
\end{align}


---
## Let $f(x)=3x+1$; $g(x)=x^7$; $h(x)=\sqrt{x}$; $k(x)=\dfrac{1}{x}$.

### 15.
\begin{align}
(f \circ g)(x) &= f(g(x)) \\
&= f(x^7) \\
&= 3(x^7) + 1 \\
&= 3x^7 + 1
\end{align}

### 16.
\begin{align}
(g \circ f)(x) &= g(f(x)) \\
&= g(3x + 1) \\
&= (3x + 1)^7
\end{align}

### 17.
\begin{align}
(f \circ h)(x) &= f(h(x)) \\
&= f(\sqrt{x}) \\
&= 3\sqrt{x} + 1
\end{align}

### 18. 
\begin{align}
(h \circ f)(x) &= h(f(x)) \\
&= h(3x + 1) \\
&= \sqrt{3x + 1}
\end{align}

### 19.
\begin{align}
(f \circ k)(x) &= f(k(x)) \\
&= f\left(\frac{1}{x}\right) \\
&= 3\left(\frac{1}{x}\right) + 1 \\
&= \frac{3}{x} + 1
\end{align}

### 20. 
\begin{align}
(k \circ f)(x) &= k(f(x)) \\
&= k(3x + 1) \\
&= \frac{1}{3x + 1}
\end{align}

---

## Decomposition of Functions

- Consider the way the above compositions look.  In the future (for people who take calculus), we will see forms like this and be asked - what composition was this?




---

### 21. $(f\circ g)(x)=(3x-8)^5$.  What are $f(x)$ and $g(x)$?

|Outside Function| Inside Function|
|---|---|
|$f(u)=u^5$| $g(x)=3x-8$|

$g$ is the inside function and $f$ is the outside function.

So $g(x)=3x-8$ and $f(x)=x^5$.


---

 ### 22. $(f\circ g)(x)=\sqrt{2x-9}$.  What are $f(x)$ and $g(x)$?
 
 |Outside Function| Inside Function|
|---|---|
|$f(u)=\sqrt{u}$| $g(x)=2x-9$|

$g$ is the inside function and $f$ is the outside function.

So $g(x)=2x-9$ and $f(x)=\sqrt{x}$.

---

### 23. $(f\circ g)(x)=\frac{1}{10x+4}$.  What are $f(x)$ and $g(x)$?

$g$ is the inside function and $f$ is the outside function.

So $g(x)=10x+4$ and $f(x)=\dfrac{1}{x}$.

|Outside Function| Inside Function|
|---|---|
|$f(u)=\dfrac{1}{u}$| $g(x)=10x+4$|