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.

# 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 parenthesis, x, right parenthesis, equals, 3, x, minus, 1 and g, left parenthesis, x, right parenthesis, equals, x, cubed, plus, 2, then what is f, left parenthesis, g, left parenthesis, 3, right parenthesis, right parenthesis?

### Solution

One way to evaluate f, left parenthesis, g, left parenthesis, 3, right parenthesis, right parenthesis is to work from the "inside out". In other words, let's evaluate g, left parenthesis, 3, right parenthesis first and then substitute that result into f to find our answer.
Let's evaluate g, left parenthesis, 3, right parenthesis.
\begin{aligned}g(x)&=x^3+2\\\\ g(3)&=({3})^3 +2~~~~~~~~~~~~~~~~~~~\small{\gray{\text{Plug in }x={3.}}}\\\\ &={29}\end{aligned}
Since g, left parenthesis, 3, right parenthesis, equals, 29, then f, left parenthesis, g, left parenthesis, 3, right parenthesis, right parenthesis, equals, f, left parenthesis, 29, right parenthesis.
Now let's evaluate f, left parenthesis, 29, right parenthesis.
\begin{aligned}f(x)&=3x-1\\\\ f( {{29}})&=3({29}) - 1~~~~~~~~~~~~~~~\small{\gray{\text{Plug in }x= {29.}}}\\\\ &={86}\\\\ \end{aligned}
It follows that f, left parenthesis, g, left parenthesis, 3, right parenthesis, right parenthesis, equals, f, left parenthesis, 29, right parenthesis, equals, 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 parenthesis, g, left parenthesis, x, right parenthesis, right parenthesis.

### Example

What is f, left parenthesis, g, left parenthesis, x, right parenthesis, right parenthesis?
For reference, remember that f, left parenthesis, x, right parenthesis, equals, 3, x, minus, 1 and g, left parenthesis, x, right parenthesis, equals, x, cubed, plus, 2.

### Solution

If we look at the expressionf, left parenthesis, start color #ca337c, g, left parenthesis, x, right parenthesis, end color #ca337c, right parenthesis, we can see that start color #ca337c, g, left parenthesis, x, right parenthesis, end color #ca337c is the input of function f. So, let's substitute start color #ca337c, g, left parenthesis, x, right parenthesis, end color #ca337c everywhere we see start color #0c7f99, x, end color #0c7f99 in function f.
\begin{aligned}f(\blueE x)&=3\blueE x-1\\\\ f(\maroonD{g(x)}) &= 3(\maroonD{g(x)})-1 \\ \end{aligned}
Since g, left parenthesis, x, right parenthesis, equals, x, cubed, plus, 2, we can substitute x, cubed, plus, 2 in for g, left parenthesis, x, right parenthesis.
\begin{aligned}{f(g(x))}&=3(g(x))-1 \\\\ &=3({x^3+2})-1 \\\\ &=3x^3+6-1\\\\ &=3x^3+5 \end{aligned}
This new function should take 3 directly to 86. Let's verify this.
\begin{aligned} f( g(x))&= 3x^3+5\\ \\ f( g( 3))&= 3( 3)^3+5 \\\\ &= {86} \end{aligned}
Excellent!

## Let's practice

### Problem 1

f, left parenthesis, x, right parenthesis, equals, 3, x, minus, 1
g, left parenthesis, x, right parenthesis, equals, x, cubed, plus, 2
Evaluate g, left parenthesis, f, left parenthesis, 1, right parenthesis, right parenthesis.

### Problem 2

m, left parenthesis, x, right parenthesis, equals, 3, x, minus, 2
n, left parenthesis, x, right parenthesis, equals, x, plus, 4
Find m, left parenthesis, n, left parenthesis, x, right parenthesis, right parenthesis.

# 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, circle, g, read as "f composed with g". This composition is defined by the following rule:
left parenthesis, f, circle, g, right parenthesis, left parenthesis, x, right parenthesis, equals, f, left parenthesis, g, left parenthesis, x, right parenthesis, right parenthesis
The diagram below shows the relationship between left parenthesis, f, circle, g, right parenthesis, left parenthesis, x, right parenthesis and f, left parenthesis, g, left parenthesis, x, right parenthesis, right parenthesis.
Now let's look at another example with this new definition in mind.

### Example

g, left parenthesis, x, right parenthesis, equals, x, plus, 4
h, left parenthesis, x, right parenthesis, equals, x, squared, minus, 2, x
Find left parenthesis, h, circle, g, right parenthesis, left parenthesis, x, right parenthesis and left parenthesis, h, circle, g, right parenthesis, left parenthesis, minus, 2, right parenthesis.

### Solution

We can find left parenthesis, h, circle, g, right parenthesis, left parenthesis, x, right parenthesis as follows:
\begin{aligned}(h\circ g)(x)&=h(g(x))&\small{\gray{\text{Define.}}}\\\\ &=(g(x))^2-2(g(x))&\small{\gray{\text{Plug } g(x) \text{ in for } x\text{ in function }h.}}\\\\ &=({x+4})^2 -2({x+4})&\small{\gray{\text{Substitute } x+4 \text{ for } g(x).}}\\\\ &=x^2+8x+16-2x-8&\small{\gray{\text{Distribute.}}}\\\\ &=x^2+6x+8&\small{\gray{\text{Combine like terms.}}}\end{aligned}
Since we now have function h, circle, g, we can simply substitute minus, 2 in for x to find left parenthesis, h, circle, g, right parenthesis, left parenthesis, minus, 2, right parenthesis.
\begin{aligned}(h\circ g)(x)&=x^2+6x+8\\\\ (h\circ g)(-2)&=(-2)^2+6(-2)+8\\\\ &=4-12+8\\\\ &=0\\\\ \end{aligned}
Of course, we could have also found left parenthesis, h, circle, g, right parenthesis, left parenthesis, minus, 2, right parenthesis by evaluating h, left parenthesis, g, left parenthesis, minus, 2, right parenthesis, right parenthesis. This is shown below:
\begin{aligned}(h\circ g)(-2)&=h(g(-2))\\\\ &=h(2)~~~~~~~~\small{\gray{\text{Since }g(-2)=-2+4=2}}\\\\ &=0~~~~~~~~~~~~~\small{\gray{\text{Since }h(2)=2^2-2(2)=0}}\\\\ \end{aligned}
The diagram below shows how left parenthesis, h, circle, g, right parenthesis, left parenthesis, minus, 2, right parenthesis is related to h, left parenthesis, g, left parenthesis, minus, 2, right parenthesis, right parenthesis.
Here we can see that function g takes minus, 2 to 2 and then function h takes 2 to 0, while function h, circle, g takes minus, 2 directly to 0.

# Now let's practice some problems

### Problem 3

f, left parenthesis, x, right parenthesis, equals, 3, x, minus, 5
g, left parenthesis, x, right parenthesis, equals, 3, minus, 2, x
Evaluate left parenthesis, g, circle, f, right parenthesis, left parenthesis, 3, right parenthesis.

In problems 4 and 5, let f, left parenthesis, t, right parenthesis, equals, t, minus, 2 and g, left parenthesis, t, right parenthesis, equals, t, squared, plus, 5.

### Problem 4

Find left parenthesis, g, circle, f, right parenthesis, left parenthesis, t, right parenthesis.

### Problem 5

Find left parenthesis, f, circle, g, right parenthesis, left parenthesis, t, right parenthesis.

# Challenge Problem

The graphs of the equations y, equals, f, left parenthesis, x, right parenthesis and y, equals, g, left parenthesis, x, right parenthesis are shown in the grid below.
Which of the following best approximates the value of left parenthesis, f, circle, g, right parenthesis, left parenthesis, 8, right parenthesis?

## 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
• Actually, where 4t was created was based of a theorem. (a-b)^2 = a^2 + b^2 - 2ab.
let a be t and b be 2 to get: t^2+2-2(-2)t. Simplify to get t^2 +4 -4t
so that is where the -4t came from.
(1 vote)
• How do you know when to use the "inside out property" or the composing function?
• I know how to use the inside property because how are the numbers and the signs that they have
(1 vote)
• (f ∘ g)(x)
here, what does the sign ∘ mean?
• here ( f ∘ g ) means the composite function of g and f
let .A,B,C three relation. where function exist from A -> B ,B ->C and also from
A -> C if and only f(x) is a subset of g(y)
• Can someone please simplify all of this for me cause i am so confused!
• If f(x)=(1/x) and (f/g)(x)=((x+4)/(x^2+2x)), what is the function g?
• Based upon the rules for dividing with fractions: f/g = (1/x) / g = (1/x) * the reciprocal of g

We need to work in reverse
1) Factor denominator to undo the multiplication: (x+4)/(x^2+2x) = (x+4)/[x(x+2)]
We can see there is a factor of X in the denominator. This would have been from multiplying 1/x * the reciprocal of g.
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)

Hope this helps.
• In problem 4, i got t^2 +9, so where did the -4t come from? I tried to find out back in the examples but it did the same. Its like taking the number inside the parenthesis and multiplying it by 2t or 2 times the variable.
=(x+4)^2−2(x+4) =x^2+8x+16−2x−8...this was the example, so where did 8x come from?
• Your mistake was simple. You didn't go about the exponent property the correct way. This is how I solved it:
(gof)(t)--->g(f(t))
g(ft)=(ft)^2+5...remember ft=(t-2)
g(t-2)=(t-2)^2+5
at this point (t-2)^2, is where you made the error. I'm sure you probably distributed the 2 instead of multiplying (t-2) twice. But instead, FOIL it, and you get the quadratic function: t^2-4t+4.
Hence, where "-4t" came from. (:
• In the last question, is there a problem with the graph because, I'm finding it difficult to understand it?
• The graph is fine, but this question pools together some concepts from other parts of math the we may have forgotten about.

f(x) is your standard linear equation of the form

f(x) = mx + b

Specifically it's

f(x) = -0.5x - 2

g(x) is a sinusoidal equation of the form

g(x) = a cos(b (x - c)) + d

Where a is the amplitude, 2π/|b| is the period, c is the phase shift, and d is the midline.

Finding a is simple enough; it's 2. The phase shift and midline both look like 0, so that's nice. The tricky part is finding b.

The period of this particular sinusoidal function appears to be 8, which means we need to solve for b where

2π/|b| = 8# Do some algebra...b = π/4

Once we have done this we can compose the functions like so

f(x) = -0.5 * x - 2g(x) = 2 * cos(π / 4 * x)f(g(x)) = -0.5 * (2 * cos(π / 4 * x)) - 2

Which we can further simplify as

f(g(x)) = -cos(π / 4 * x) - 2

Of course you could forgo composing the functions and evaluate each function separately. Either way, you'll find that f(g(x)) ~= -3.

Here's a graph of everything: https://www.desmos.com/calculator/b0r64jqiqv
• what if its f o f (x)? will it be f(x)^2?
i heard that there's a definition that states that
f o f o f ....(n times)= f(x)^n
is it true?