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:

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 , it follows that the temperature they experience after 12 minutes is .

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

Then, to calculate , we substitute every occurrence of in with , as follows:

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

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 and , 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 , we have

Now we can substitute in . This just means that we take and replace the argument with . This gives us

In conclusion, we have .

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 and , find .

### Answer

Recall, from the definition, that we have

In this question, we have to evaluate the above expression at ; that is,

We begin by substituting in the expression for and evaluating it at 2, as follows:

Now we simply substitute in and evaluate it at 5:

Thus, .

### 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 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 ?

### Answer

To calculate , we start from the inside of the expression and calculate and then substitute this value into .

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

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

So, . Overall, this gives us .

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 . Find .

### Answer

Using the logic above, we are being asked to calculate

This might look tricky at first, but note that we do not actually have to calculate . We simply need to calculate and then apply to the result multiple times. Let us do this below:

So, in conclusion, we have .

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

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:

- 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 .
- Second, find the domain of . So, find any values of such that is not defined. Let this set of values be .
- 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 , where , and the function , 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:

- Find any values of such that is undefined. Exclude them from the domain.
- Find any values of such that is undefined. Take note of them.
- 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 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 is undefined. This function cannot take , since that would result in division by 0, which is undefined. So, we take note of .

Finally, we see whether there are values of such that , that is,

By adding 41 to both sides, we find

Thus, is a value we have to exclude from the domain. In conclusion, the domain of .

### 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 and , the first set is . Now we want to find the range of given that the domain is . Let us examine the graph of this function.

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

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 .