Lesson Explainer: Composite Functions Mathematics

In this explainer, we will learn how to form a composite function by composing two or more functions.

Let us begin by recalling the definition of a function and a domain, along with some notation we will be using in this explainer.

Definition: Functions and Domains

A function 𝑓𝑋𝑌 is a relation that sends elements from the domain 𝑋 to the codomain 𝑌. The domain is defined to be the set of all possible inputs 𝑥 of the function such that 𝑓(𝑥) is defined.

Now, to help explain composite functions, let us consider the following analogy. Suppose a cyclist is traveling along a mountainous path. As they go up and down the mountain, their altitude 𝑧 (in metres above sea level) varies with respect to the time 𝑡 since they started cycling (in minutes). Let us suppose this altitude is given by the function 𝑧=𝑍(𝑡).

Let us also suppose that in the region that the cyclist is traveling, the temperature (in degrees Celsius) depends only on the altitude. So no matter where exactly they are, their altitude determines their temperature. In other words, the temperature 𝑇(𝑧) is a function of altitude 𝑧.

Thus, since the temperature can be calculated from the altitude, and the altitude can be calculated from the time elapsed, the temperature can be calculated from the time elapsed, as follows: timealtitudetemperature𝑡𝑧=𝑍(𝑡)𝑇(𝑧)=𝑇(𝑍(𝑡))

For instance, if after 12 minutes the cyclist is at an altitude of 335 m, and it is known that the temperature at 335 m is 14C, it follows that the temperature they experience after 12 minutes is 14C.

This process is known as function composition. The new function we have created, 𝑡𝑇(𝑍(𝑡)), is a composite function. We can formally define composite functions as follows.

Definition: Composite Functions

Let 𝑓 and 𝑔 be functions. Then, the composite function 𝑔𝑓 is defined by (𝑔𝑓)(𝑥)=𝑔(𝑓(𝑥)).

Note that the order of 𝑔𝑓 (pronounced “𝑔 of 𝑓”) is important; this applies 𝑓 to 𝑥 first, followed by 𝑔. The precise domain of 𝑔𝑓 is slightly tricky to figure out; hence, we will return to it later on in the explainer.

For now, let us consider a concrete example of calculating composite functions. Suppose we have the functions 𝑓(𝑥)=3𝑥+𝜋,𝑓,𝑔(𝑥)=2𝑥+𝑥1,𝑔.

Then, to calculate 𝑔𝑓, we substitute every occurrence of 𝑥 in 𝑔(𝑥) with 𝑓(𝑥), as follows: (𝑔𝑓)(𝑥)=𝑔(𝑓(𝑥))=𝑔(3𝑥+𝜋)=2(3𝑥+𝜋)+(3𝑥+𝜋)1=29𝑥+6𝜋𝑥+𝜋+3𝑥+𝜋1=18𝑥+(12𝜋+3)𝑥+2𝜋+𝜋1.

Another way to think of this is that we substitute the innermost values first (in this case 𝑓(𝑥)) and work outward.

Alternatively, we could compose them in the opposite order. We would have (𝑓𝑔)(𝑥)=𝑓(𝑔(𝑥))=𝑓2𝑥+𝑥1=32𝑥+𝑥1+𝜋=6𝑥+3𝑥3+𝜋.

It is important to note that 𝑓𝑔𝑔𝑓. In fact, generally speaking, it may not always be possible to compose functions in the opposite order, depending on the domains and ranges. This leads to the following rule.

Rule: Commutativity of the Composition of Functions

The composition of functions is not commutative. This means that for two functions 𝑓 and 𝑔, 𝑓𝑔 is not the same as 𝑔𝑓. The two operations are only equal under specific circumstances (e.g., 𝑓=𝑔).

We have now been introduced to function composition and some of the properties it has. Let us test our knowledge with the following example.

Example 1: Finding the Expression of a Composite Function

If 𝑓(𝑥)=3 and 𝑔(𝑥)=𝑥2, what is (𝑓𝑔)(𝑥)?

Answer

Recall that, from the definition of a composite function, (𝑓𝑔)(𝑥)=𝑓(𝑔(𝑥)).

To evaluate a composite function, we substitute in the expressions for 𝑔 and 𝑓, starting from the inside and going outward. The innermost expression is 𝑔(𝑥); therefore, substituting in 𝑔(𝑥)=𝑥2, we have 𝑓(𝑔(𝑥))=𝑓(𝑥2).

Now we can substitute in 𝑓(𝑥)=3. This just means that we take 3 and replace the argument 𝑥 with 𝑥2. This gives us 𝑓(𝑥2)=3.

In conclusion, we have (𝑓𝑔)(𝑥)=3.

We have now seen a couple of basic examples of how function composition works. Sometimes, we may be asked to evaluate composite functions at a specific point. As we will see in the next example, this is actually easier than computing the entire function.

Example 2: Evaluating Composite Functions at a Given Value

Given 𝑓(𝑥)=3𝑥1 and 𝑔(𝑥)=𝑥+1, find (𝑓𝑔)(2).

Answer

Recall, from the definition, that we have (𝑓𝑔)(𝑥)=𝑓(𝑔(𝑥)).

In this question, we have to evaluate the above expression at 𝑥=2; that is, (𝑓𝑔)(2)=𝑓(𝑔(2)).

We begin by substituting in the expression for 𝑔(𝑥) and evaluating it at 2, as follows: 𝑓(𝑔(2))=𝑓2+1=𝑓(5).

Now we simply substitute in 𝑓(𝑥)=3𝑥1 and evaluate it at 5: 𝑓(𝑔(2))=3(5)1=14.

Thus, (𝑓𝑔)(2)=14.

Note

We did not have to work out the full expression for (𝑓𝑔)(𝑥) here to evaluate it at a certain value. If it had been necessary, we could have calculated (𝑓𝑔)(𝑥)=3𝑥+2 first and evaluated it at 2 to get 14.

Evaluation of composite functions can be done using the expressions of the component functions, as we saw in the previous example. Equally, we can evaluate them using graphs of the component functions, which we will show in the next example.

Example 3: Evaluating Composite Functions at a Given Value from Their Graphs

In the given figure, the red graph represents 𝑦=𝑓(𝑥), while the blue represents 𝑦=𝑔(𝑥).

What is 𝑓(𝑔(2))?

Answer

To calculate 𝑓(𝑔(2)), we start from the inside of the expression and calculate 𝑔(2) and then substitute this value into 𝑓.

To find 𝑔(2) from the graph, we draw a line segment from the 𝑥-axis at 𝑥=2 to the curve for 𝑔(𝑥) (the blue curve) and project it onto the 𝑦-axis. We show this below.

This gives us 𝑔(2)=1. Thus, we have 𝑓(𝑔(2))=𝑓(1). To calculate 𝑓(1), we return to the diagram and follow the same procedure; we draw a line from the 𝑥-axis at 𝑥=1 to the line for 𝑓(𝑥) (the red curve) and follow it to the 𝑦-axis, as shown below.

So, 𝑓(1)=3. Overall, this gives us 𝑓(𝑔(2))=3.

Up until now, we have only seen a function composed with one other function at a time, but we can extend this to composing multiple functions together by simply using the definition of function composition multiple times. For instance, (𝑓𝑔)(𝑥)=𝑓(𝑔((𝑥))).

In the next example, we will see how this works if we compose the same function with itself multiple times.

Example 4: Evaluating the Composite of a Function with Itself Multiple Times at a Given Value

Set 𝑓=𝑓𝑓(), 𝑓=𝑓𝑓𝑓(), and so on such that 𝑓(𝑥)=𝑓(𝑓(𝑥))(), 𝑓(𝑥)=𝑓(𝑓(𝑓(𝑥)))(), and so on. Suppose 𝑔(𝑥)=4𝑥5. Find 𝑔(3)().

Answer

Using the logic above, we are being asked to calculate 𝑔(3)=𝑔(𝑔(𝑔(𝑔(3)))).()

This might look tricky at first, but note that we do not actually have to calculate 𝑔(𝑥)(). We simply need to calculate 𝑔(3) and then apply 𝑔 to the result multiple times. Let us do this below: 𝑔(3)=4(3)5=7,𝑔(𝑔(3))=𝑔(7)=4(7)5=23,𝑔(𝑔(𝑔(3)))=𝑔(23)=4(23)5=87,𝑔(𝑔(𝑔(𝑔(3))))=𝑔(87)=4(87)5=343.

So, in conclusion, we have 𝑔(3)=343().

Earlier, we said we would return to the issue of the domain of a composite function, so let us explore that concept now.

Suppose we have two functions 𝑓𝑋𝑊 and 𝑔𝑌𝑍. Since 𝑔𝑓=𝑔(𝑓(𝑥)), the values 𝑥 can take are dependent on both 𝑓 and 𝑔. Let us consider this as a diagram.

Here we can see that 𝑓𝑋𝑊,𝑥𝑋;𝑔𝑌𝑍,𝑓(𝑥)𝑌,𝑔(𝑓(𝑥))𝑍.andhencemustbelongtoandhencemustbelongtoand

Thus, the domain of 𝑔𝑓 has two restrictions on it. Firstly, it is dependent on the domain of 𝑓, since 𝑓(𝑥) can only take 𝑥𝑋. Secondly, 𝑓(𝑥) must be a valid input for 𝑔, which means we have to restrict the domain of 𝑓 so that 𝑓(𝑥) is always in the domain of 𝑔. Thus, to find the domain of a composite function, we have the following method.

How To: Finding the Domain of a Composite Function

Suppose we want to find the domain of 𝑔𝑓. Then, we do the following:

  1. First, find the domain of 𝑓. To do this, find any values of 𝑥 such that 𝑓(𝑥) is not defined. This could be a set of points or an interval. If there are any, exclude them from the domain of 𝑔𝑓.
  2. Second, find the domain of 𝑔. So, find any values of 𝑥 such that 𝑔(𝑥) is not defined. Let this set of values be 𝑌.
  3. Finally, for each 𝑦𝑌, find what values of 𝑥 satisfy 𝑓(𝑥)=𝑦. If there are any, exclude these values from the domain of 𝑔𝑓 too.

To best demonstrate this procedure, let us consider the following example.

Example 5: Determining the Domain of a Composite Function

If the function 𝑓(𝑥)=2𝑥, where 𝑥0, and the function 𝑔(𝑥)=𝑥41, determine the domain of 𝑓𝑔.

Answer

Recall that, by definition, we have 𝑓𝑔=𝑓(𝑔(𝑥)).

To determine the domain of 𝑓(𝑔(𝑥)), we must make sure that any 𝑥 going into 𝑔(𝑥) is valid and that any 𝑔(𝑥) going into 𝑓() is valid. We can make sure of this with the following procedure:

  1. Find any values of 𝑥 such that 𝑔(𝑥)=𝑥41 is undefined. Exclude them from the domain.
  2. Find any values of 𝑥 such that 𝑓(𝑥)=2𝑥 is undefined. Take note of them.
  3. Find what values of 𝑥 give us 𝑔(𝑥) equal to the noted values. Exclude them from the domain.

For step 1, we ask ourselves whether there are any values such that 𝑔(𝑥)=𝑥41 is undefined. Since we can subtract 41 from any real number without any issues, there are no such values. So we do not have to do anything for the first step.

For the second step, we need to find values of 𝑥 such that 𝑓(𝑥)=2𝑥 is undefined. This function cannot take 𝑥=0, since that would result in division by 0, which is undefined. So, we take note of 𝑥=0.

Finally, we see whether there are values of 𝑥 such that 𝑔(𝑥)=0, that is, 𝑥41=0.

By adding 41 to both sides, we find 𝑥=41.

Thus, 𝑥=41 is a value we have to exclude from the domain. In conclusion, the domain of 𝑓𝑔={41}.

Note

It is also possible to calculate the range of 𝑓𝑔. To do this, we take the domain and find the set of values we get after successively applying 𝑔 then 𝑓. Given that the domain is {41} and 𝑔(𝑥)=𝑥41, the first set is {0}. Now we want to find the range of 𝑓(𝑥)=2𝑥 given that the domain is {0}. Let us examine the graph of this function.

As we can see, we can get any value of 𝑦 from applying 𝑓, except for 𝑦=0. This is because as 𝑥 approaches or , 2𝑥 gets very small but never actually reaches 0, since there is no value of 𝑥 such that 2𝑥=0. Thus, the range of 𝑓𝑔 is {0}.

Let us finish by recapping the main things we have learned in this explainer.

Key Points

  • Let 𝑓 and 𝑔 be functions. Then, the composite function 𝑔𝑓 is defined by (𝑔𝑓)(𝑥)=𝑔(𝑓(𝑥)).
  • We can compute 𝑔(𝑓(𝑥)) by replacing each instance of 𝑥 in 𝑔(𝑥) by 𝑓(𝑥).
  • The composition of functions is not commutative. This means that for two functions 𝑓 and 𝑔, 𝑓𝑔 is not the same as 𝑔𝑓.
  • We can determine the domain of 𝑔𝑓 by finding the domains of 𝑓 and 𝑔 and excluding all points 𝑥 that are undefined for 𝑓(𝑥) and 𝑔(𝑓(𝑥)) from the domain of 𝑔𝑓.

Nagwa uses cookies to ensure you get the best experience on our website. Learn more about our Privacy Policy.