If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

### Course: Algebra (all content)>Unit 7

Lesson 15: Composing functions (Algebra 2 level)

# Composing functions

Walk through examples, explanations, and practice problems to learn how to find and evaluate composite functions.
Given two functions, we can combine them in such a way so that the outputs of one function become the inputs of the other. This action defines a composite function. Let's take a look at what this means!

# Evaluating composite functions

### Example

If $f\left(x\right)=3x-1$ and $g\left(x\right)={x}^{3}+2$, then what is $f\left(g\left(3\right)\right)$?

### Solution

One way to evaluate $f\left(g\left(3\right)\right)$ is to work from the "inside out". In other words, let's evaluate $g\left(3\right)$ first and then substitute that result into $f$ to find our answer.
Let's evaluate $g\left(3\right)$.
Since $g\left(3\right)=29$, then $f\left(g\left(3\right)\right)=f\left(29\right)$.
Now let's evaluate $f\left(29\right)$.
It follows that $f\left(g\left(3\right)\right)=f\left(29\right)=86$.

# Finding the composite function

In the above example, function $g$ took $3$ to $29$, and then function $f$ took $29$ to $86$. Let's find the function that takes $3$ directly to $86$.
To do this, we must compose the two functions and find $f\left(g\left(x\right)\right)$.

### Example

What is $f\left(g\left(x\right)\right)$?
For reference, remember that $f\left(x\right)=3x-1$ and $g\left(x\right)={x}^{3}+2$.

### Solution

If we look at the expression$f\left(g\left(x\right)\right)$, we can see that $g\left(x\right)$ is the input of function $f$. So, let's substitute $g\left(x\right)$ everywhere we see $x$ in function $f$.
$\begin{array}{rl}f\left(x\right)& =3x-1\\ \\ f\left(g\left(x\right)\right)& =3\left(g\left(x\right)\right)-1\end{array}$
Since $g\left(x\right)={x}^{3}+2$, we can substitute ${x}^{3}+2$ in for $g\left(x\right)$.
$\begin{array}{rl}f\left(g\left(x\right)\right)& =3\left(g\left(x\right)\right)-1\\ \\ & =3\left({x}^{3}+2\right)-1\\ \\ & =3{x}^{3}+6-1\\ \\ & =3{x}^{3}+5\end{array}$
This new function should take $3$ directly to $86$. Let's verify this.
$\begin{array}{rl}f\left(g\left(x\right)\right)& =3{x}^{3}+5\\ \\ f\left(g\left(3\right)\right)& =3\left(3{\right)}^{3}+5\\ \\ & =86\end{array}$
Excellent!

## Let's practice

### Problem 1

$f\left(x\right)=3x-1$
$g\left(x\right)={x}^{3}+2$
Evaluate $g\left(f\left(1\right)\right)$.

### Problem 2

$m\left(x\right)=3x-2$
$n\left(x\right)=x+4$
Find $m\left(n\left(x\right)\right)$.

# Composite functions: a formal definition

In the above example, we found and evaluated a composite function.
In general, to indicate function $f$ composed with function $g$, we can write $f\circ g$, read as "$f$ composed with $g$". This composition is defined by the following rule:
$\left(f\circ g\right)\left(x\right)=f\left(g\left(x\right)\right)$
The diagram below shows the relationship between $\left(f\circ g\right)\left(x\right)$ and $f\left(g\left(x\right)\right)$.
Now let's look at another example with this new definition in mind.

### Example

$g\left(x\right)=x+4$
$h\left(x\right)={x}^{2}-2x$
Find $\left(h\circ g\right)\left(x\right)$ and $\left(h\circ g\right)\left(-2\right)$.

### Solution

We can find $\left(h\circ g\right)\left(x\right)$ as follows:
Since we now have function $h\circ g$, we can simply substitute $-2$ in for $x$ to find $\left(h\circ g\right)\left(-2\right)$.
$\begin{array}{rl}\left(h\circ g\right)\left(x\right)& ={x}^{2}+6x+8\\ \\ \left(h\circ g\right)\left(-2\right)& =\left(-2{\right)}^{2}+6\left(-2\right)+8\\ \\ & =4-12+8\\ \\ & =0\\ \end{array}$
Of course, we could have also found $\left(h\circ g\right)\left(-2\right)$ by evaluating $h\left(g\left(-2\right)\right)$. This is shown below:
The diagram below shows how $\left(h\circ g\right)\left(-2\right)$ is related to $h\left(g\left(-2\right)\right)$.
Here we can see that function $g$ takes $-2$ to $2$ and then function $h$ takes $2$ to $0$, while function $h\circ g$ takes $-2$ directly to $0$.

# Now let's practice some problems

### Problem 3

$f\left(x\right)=3x-5$
$g\left(x\right)=3-2x$
Evaluate $\left(g\circ f\right)\left(3\right)$.

In problems 4 and 5, let $f\left(t\right)=t-2$ and $g\left(t\right)={t}^{2}+5$.

### Problem 4

Find $\left(g\circ f\right)\left(t\right)$.

### Problem 5

Find $\left(f\circ g\right)\left(t\right)$.

# Challenge Problem

The graphs of the equations $y=f\left(x\right)$ and $y=g\left(x\right)$ are shown in the grid below.
Which of the following best approximates the value of $\left(f\circ g\right)\left(8\right)$?

## Want to join the conversation?

• In practice Q 4, where is 4t created? I see where t^2 and 4 come from, but am not sure what puts 4t in
• I was stuck on this too, but I think the reason is that (t-2)^2 = (t-2)(t-2) . Using the distributive property, you get t^2-4t+4.
• (f ∘ g)(x)
here, what does the sign ∘ mean?
• (f ∘ g)(x) is read "f of g of x", so the ∘ translates to "of".
In this case, if you had functions defined, f(x) and g(x), then to get (f ∘ g)(x) you would substitute g(x) for x inside of f(x). Another way to write it is f(g(x)).
• How do you know when to use the "inside out property" or the composing function?
• It doesn't really matter --- they will both give the same answer, so it's up to you to choose what works best/easiest for you with the problem you're given at the time!
(But, of course, you need to be familiar with both techniques.)
• May someone please explain the challenge problem to me?
• The challenge problem says, "The graphs of the equations y=f(x) and y=g(x) are shown in the grid below." So basically the two graphs is a visual representation of what the two different functions would look like if graphed and they're asking us to find (f∘g)(8), which is combining the two functions and inputting 8. From the definition, we know (f∘g)(8)=f(g(8)). So let's work "inside out". If we look at the graph of "g", we see that g(8) is 2 (look at the 8 at the x-axis and if you go up to where it meets the line, the y value would be 2). Because g(8)=2, then when you substitute it back in the equation, f(g(8)) would equal f(2). Then if we look at the graph of "f", we can see that f(2) is -3. (when you look at the 2 in the x-axis, it will correspond to -3 on the y-axis). So by looking at the graph, you can figure out that (f∘g)(8) is approximately -3.
~Dylan
• In question 4 how do people get the 4t in tsquered-t4+9?
• It comes from (t-2)^2
(t-2)^2 = (t-2)(t-2) = t^2-2t-2t+4 = t^2-4t+4
To square binomials, you need to use FOIL or the pattern for creating a perfect square trinomial. You can't square the 2 terms and get the right answer.

Hope this helps.
• in the example question "g(x)= x+4, h(x)= x(squared)-2x" how does it get the +8x and -2x in the distribute section ?
here's the distribute equation =(x(squared)+8x+16−2x−8)
• h(g(x)) = (x+4)^2 - 2(x+4)
Basically each "x" in h(x) gets replaced with (x+4), which if g(x). Then, you simplify.

1) FOIL out (x+4)^2:
h(g(x)) = x^2+4x+4x+16 - 2(x+4) = x^2 + 8x + 16 - 2(x+4)

2) Distribute -2: h(g(x)) = x^2 + 8x + 16 - 2x - 8

3) Combine like terms: x^2 + 6x + 8

Hope this helps.
• I still can't get this. I think my problem is them showing multiple ways to do this instead of focusing on how to combine it into one equation. Either I have to work each function alone then combine them at the end or have more help figuring out how to make one equation.
• I don't think their aim is to show you the multiple ways you can evaluate the composite function.

The first example they basically show what evaluating a composite function really means, it's like you said "work each function alone". In the second example they showed a more faster and efficient way to evaluate the composite function by combining them into one equation.

If you're still confused about composite functions, I'll explain this way:

we have a function f(x), this function takes "x" as "input". Now, I'm certain you're used to the variable x being substituted for a number, but in maths, you can pretty much substitute it for anything you like. (Expressions for example)

Like I can let x = 5, but I can also let x = 2h. Doesn't that mean I can also substitute x for some function? In other words x = g(x).

Say if g(k) = 4k, then this would become: x = 4k. (Because x = g(k) = 4k)

Since we let x = g(k) = 4k, then our function f can be written as: f( g(k) ) or f(5k) (We substituted x for g(k) )

if f(x) = 5x, by substituting x for g(k), this becomes:

f( g(x) ) = 5g(x) ---> f( 4k ) = 5(4k) = 20k

This also means that our composite function changes value depending on the value of k.

Conclusion: g(k) becomes input for function f.
• Can someone please simplify all of this for me cause i am so confused!
• Number 3 is hard can u give better explanations
• The way I understand it and I solve it is to always split solution in to steps where each step is solving just single function:

f(x) = 3x-5
g(x) = 3-2x
(g∘f)(3)

1. We'll solve f(x) as it's on the end. We know that x is 3 so we need to calculate 3*3-5 which is 4

2. We'll solve g(x). g(x) is wrapping up f(x) so it might look something like g(f(x)) = 3-2(fx) = 3-2(3x-5).

As we know from step 1 that f(x) = 4 we can just use it as x variable for g. So equation should be g(x) = 3-2*4

Esentially you can just focus on single function and use your result as x of next function.

I hope this is helpful and not more confusing.
• If f(x)=(1/x) and (f/g)(x)=((x+4)/(x^2+2x)), what is the function g?
1) Factor denominator to undo the multiplication: (x+4)/(x^2+2x) = (x+4)/[x(x+2)]
2) Separate the factor 1/x: (1/x) * (x+4)/(x+2)
This tells us the reciprocal of g = (x+4)/(x+2)
3) Flip it to find g: g(x) = (x+2)/(x+4)