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.

Main content

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(x)=3x1 and g(x)=x3+2, then what is f(g(3))?

Solution

One way to evaluate f(g(3)) is to work from the "inside out". In other words, let's evaluate g(3) first and then substitute that result into f to find our answer.
Let's evaluate g(3).
g(x)=x3+2g(3)=(3)3+2                   Plug in x=3.=29
Since g(3)=29, then f(g(3))=f(29).
Now let's evaluate f(29).
f(x)=3x1f(29)=3(29)1               Plug in x=29.=86
It follows that f(g(3))=f(29)=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(g(x)).

Example

What is f(g(x))?
For reference, remember that f(x)=3x1 and g(x)=x3+2.

Solution

If we look at the expressionf(g(x)), we can see that g(x) is the input of function f. So, let's substitute g(x) everywhere we see x in function f.
f(x)=3x1f(g(x))=3(g(x))1
Since g(x)=x3+2, we can substitute x3+2 in for g(x).
f(g(x))=3(g(x))1=3(x3+2)1=3x3+61=3x3+5
This new function should take 3 directly to 86. Let's verify this.
f(g(x))=3x3+5f(g(3))=3(3)3+5=86
Excellent!

Let's practice

Problem 1

f(x)=3x1
g(x)=x3+2
Evaluate g(f(1)).
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3/5
  • a simplified improper fraction, like 7/4
  • a mixed number, like 1 3/4
  • an exact decimal, like 0.75
  • a multiple of pi, like 12 pi or 2/3 pi

Problem 2

m(x)=3x2
n(x)=x+4
Find m(n(x)).

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

Example

g(x)=x+4
h(x)=x22x
Find (hg)(x) and (hg)(2).

Solution

We can find (hg)(x) as follows:
(hg)(x)=h(g(x))Define.=(g(x))22(g(x))Plug g(x) in for x in function h.=(x+4)22(x+4)Substitute x+4 for g(x).=x2+8x+162x8Distribute.=x2+6x+8Combine like terms.
Since we now have function hg, we can simply substitute 2 in for x to find (hg)(2).
(hg)(x)=x2+6x+8(hg)(2)=(2)2+6(2)+8=412+8=0
Of course, we could have also found (hg)(2) by evaluating h(g(2)). This is shown below:
(hg)(2)=h(g(2))=h(2)        Since g(2)=2+4=2=0             Since h(2)=222(2)=0
The diagram below shows how (hg)(2) is related to h(g(2)).
Here we can see that function g takes 2 to 2 and then function h takes 2 to 0, while function hg takes 2 directly to 0.

Now let's practice some problems

Problem 3

f(x)=3x5
g(x)=32x
Evaluate (gf)(3).
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3/5
  • a simplified improper fraction, like 7/4
  • a mixed number, like 1 3/4
  • an exact decimal, like 0.75
  • a multiple of pi, like 12 pi or 2/3 pi

In problems 4 and 5, let f(t)=t2 and g(t)=t2+5.

Problem 4

Find (gf)(t).

Problem 5

Find (fg)(t).

Challenge Problem

The graphs of the equations y=f(x) and y=g(x) are shown in the grid below.
Which of the following best approximates the value of (fg)(8)?
Choose 1 answer: