Skip to main content
\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)
Mathematics LibreTexts

6.4: Composition of Functions

  • Page ID
    7070
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    PREVIEW ACTIVITY \(\PageIndex{1}\): Constructing a New Function

    Let \(A = \{a, b, c, d\}\), \(B = \{p, q, r\}\), and \(C = \{s, t, u, v\}\). The arrow diagram in Figure 6.6 shows two functions: \(f: A \to B\) and \(g: B \to C\). Notice that if \(x \in A\), then \(f(x) \in B\). Since \(f(x) \in B\), we can apply the function \(g\) to \(f(x)\), and we obtain \(g(f(x))\), which is an element of \(C\).

    Using this process, determine \(g(f(a))\), \(g(f(b))\), \(g(f(c))\), and \(g(f(d))\). Then explain how we can use this information to define a function from \(A\) to \(C\).

    imageedit_3_6667660914.png

    Figure 6.6: Arrow Diagram Showing Two Functions

    PREVIEW ACTIVITY \(\PageIndex{1}\): Verbal Descriptions of Functions

    The outputs of most real functions we have studied in previous mathematics courses have been determined by mathematical expressions. In many cases, it is possible to use these expressions to give step-by-step verbal descriptions of how to compute the outputs. For example, if

    \(f: \mathbb{R} \to \mathbb{R}\) is defined by \(f(x) = (3x + 2)^3\),

    we could describe how to compute the outputs as follows:

    Step Verbal Description Symbolic Result
    1 Choose an input. \(x\)
    2 Multiply by 3. \(3x\)
    3 Add 2. \(3x + 2\)
    4 Cube the result. \((3x + 3)^3\)

    Complete step-by-step verbal descriptions for each of the following functions.

    1. \(f: \mathbb{R} \to \mathbb{R}\) by \(f(x) = \sqrt{3x^2 + 2}\), for each \(x \in \mathbb{R}\).
    2. \(g: \mathbb{R} \to \mathbb{R}\) by \(g(x) = \sin(3x^2 + 2)\), for each \(x \in \mathbb{R}\).
    3. \(h: \mathbb{R} \to \mathbb{R}\) by \(h(x) = e^{3x^2 + 2}\), for each \(x \in \mathbb{R}\).
    4. \(G: \mathbb{R} \to \mathbb{R}\) by \(G(x) = \ln(x^4 + 3)\), for each \(x \in \mathbb{R}\).
    5. \(k: \mathbb{R} \to \mathbb{R}\) by \(k(x) = \sqrt[3] {\dfrac{\sin(4x + 3)}{x^2 + 1}}\), for each \(x \in \mathbb{R}\).

    Composition of Functions

    There are several ways to combine two existing functions to create a new function. For example, in calculus, we learned how to form the product and quotient of two functions and then how to use the product rule to determine the derivative of a product of two functions and the quotient rule to determine the derivative of the quotient of two functions. The chain rule in calculus was used to determine the derivative of the composition of two functions, and in this section, we will focus only on the composition of two functions. We will then consider some results about the compositions of injections and surjections.

    The basic idea of function composition is that when possible, the output of a function \(f\) is used as the input of a function \(g\). This can be referred to as “\(f\) followed by \(g\)” and is called the composition of \(f\) and \(g\). In previous mathematics courses, we used this idea to determine a formula for the composition of two real functions.

    For example, if

    \(f(x) = 3x^2 + 2\) and \(g(x) = sin x\)

    then we can compute \(g(f(x))\) as follows:

    \[\begin{array} {rcl} {g(f(x))} &= & {g(3x^2 + 2)}\\ {} &= & {sin(3x^2 + 2).} \end{array}\]

    In this case, \(f(x)\), the output of the function \(f\), was used as the input for the function \(g\). We now give the formal definition of the composition of two functions.

    Definition: composite function

    Let \(A\), \(B\), and \(C\) be nonempty sets, and let \(f: A \to B\) and \(g: B \to C\) be functions. The composition of \(f\) and \(g\) is the function \(g \circ f: A \to C\) defined by

    \((g \circ f)(x) = g(f(x))\)

    for all \(x \in A\). We often refer to the function \(g \circ f\) as a composite function.

    It is helpful to think of composite function \(g \circ f\) as "\(f\) followed by \(g\)". We then refer to \(f\) as the inner function and \(g\) as the outer function.

    Composition and Arrow Diagrams

    The concept of the composition of two functions can be illustrated with arrow diagrams when the domain and codomain of the functions are small, finite sets. Although the term “composition” was not used then, this was done in Preview Activity \(\PageIndex{1}\), and another example is given here.

    Let \(A = \{a, b, c, d\}\), \(B = \{p, q, r\}\), and \(C = \{s, t, u, v\}\). The arrow diagram in Figure 6.7 shows two functions: \(f: A \to B\) and \(g: B \to C\).

    屏幕快照 2019-04-01 下午4.00.46.png

    If we follow the arrows from the set \(A\) to the set \(C\) , we will use the outputs of \(f\) as inputs of \(g\), and get the arrow diagram from \(A\) to \(C\) shown in Figure 6.8. This diagram represents the composition of \(f\) followed by \(g\).

    屏幕快照 2019-04-01 下午4.01.53.png

    Progress Check 6.17 (The Composition of Two Functions)

    Let \(A = \{a, b, c, d\}\) and \(B = \{1, 2, 3\}\). Define the function \(f\) and \(g\) as follows:

    \(f: A \to B\) defined by \(f(a) = 2\), \(f(b) = 3\), \(f(c) = 1\), and \(f(d) = 2\).

    \(g: A \to B\) defined by \(g(1) = 3\). \(g(2) = 1\), and \(g(3) = 2\).

    Create arrow diagrams for the function \(f\), \(g\), \(g \circ f\), and \(g \circ g\).

    Answer

    Add texts here. Do not delete this text first.

    Decomposing Functions

    We use the chain rule in calculus to find the derivative of a composite function. The first step in the process is to recognize a given function as a composite function. This can be done in many ways, but the work in Preview Activity \(\PageIndex{2}\) can be used to decompose a function in a way that works well with the chain rule. The use of the terms “inner function” and “outer function” can also be helpful. The idea is that we use the last step in the process to represent the outer function, and the steps prior to that to represent the inner function. So for the function,

    \(f: \mathbb{R} \to \mathbb{R}\) by \(f(x) = (3x + 2)^3\),

    the last step in the verbal description table was to cube the result. This means that we will use the function \(g\) (the cubing function) as the outer function and will use the prior steps as the inner function. We will denote the inner function by \(h\). So we let \(h: \mathbb{R} \to \mathbb{R}\) by \(h(x) = 3x + 2\) and \(g: \mathbb{R} \to \mathbb{R}\) by \(g(x) = x^3\). Then

    \[\begin{array} {rcl} {(g \circ h)(x)} &= & {g(h(x))} \\ {} &= & {g(3x + 2)} \\ {} &= & {(3x + 2)^3} \\ {} &= & {f(x).} \end{array}\]

    We see that \(g \circ h = f\) and, hence, we have “decomposed” the function \(f\). It should be noted that there are other ways to write the function \(f\) as a composition of two functions, but the way just described is the one that works well with the chain rule. In this case, the chain rule gives

    \[\begin{array} {rcl} {f \prime (x)} &= & {(g \circ h)\prime (x)} \\ {} &= & {g \prime (h(x)) h \prime(x)} \\ {} &= & {3(h(x))^2 \cdot 3} \\ {} &= & {g(3x + 2)^2} \end{array}\]

    Progress Check 6.18 (Decomposing Functions

    Write each of the following functions as the composition of two functions.

    1. \(F: \mathbb{R} \to \mathbb{R}\) by \(F(x) = (x^2 + 3)^3\)
    2. \(G: \mathbb{R} \to \mathbb{R}\) by \(G(x) = In(x^2 + 3)\)
    3. \(f: \mathbb{Z} \to \mathbb{Z}\) by \(f(x) = |x^2 - 3|\)
    4. \(g: \mathbb{R} \to \mathbb{R}\) by \(g(x) = cos(\dfrac{2x - 3}{x^2 + 1})\)
    Answer

    Add texts here. Do not delete this text first.

    Theorems about Composite Functions

    If \(f: A \to B\) and \(g: B \to C\), then we can form the composite function \(g \circ f: A \to C\). In Section 6.3, we learned about injections and surjections. We now explore what type of function \(g \circ f\) will be if the functions \(f\) and \(g\) are injections (or surjections).

    Progress Check 6.19: Compositions of Injections and Surjections

    Although other representations of functions can be used, it will be helpful to use arrow diagrams to represent the functions in this progress check. We will use the following sets:

    \(A = \{a, b, c\}\), \(B = \{p, q, r\}\), \(C = \{u,v, w, x\}\), and \(D = \{u, v\}\).

    1. Draw an arrow diagram for a function \(f: A \to B\) that is an injection and an arrow diagram for a function \(g: B \to C\) that is an injection. In this case, is the composite function \(g \circ f: A \to C\) an injection? Explain.
    2. Draw an arrow diagram for a function \(f: A \to B\) that is a surjection and an arrow diagram for a function \(g: B \to D\) that is a surjection. In this case, is the composite function \(g \circ f: A \to D\) a surjection? Explain.
    3. Draw an arrow diagram for a function \(f: A \to B\) that is a bijection and an arrow diagram for a function \(g: B \to A\) that is a bijection. In this case, is the composite function \(g \circ f: A \to A\) bijection? Explain.
    Answer

    Add texts here. Do not delete this text first.

    In Progress Check 6.19, we explored some properties of composite functions related to injections, surjections, and bijections. The following theorem contains results that these explorations were intended to illustrate. Some of the proofs will be included in the exercises.

    Theorem 6.20.

    Let \(A\), \(B\), and \(C\) be nonempty sets and assume that \(f: A \to B\) and \(g: B \to C\).

    1. If \(f\) and \(g\) are both injections, then \((g \circ f): A \to C\) is an injection.
    2. If \(f\) and \(g\) are both surjections, then \((g \circ f): A \to C\) is an surjection.
    3. If \(f\) and \(g\) are both bijections, then \((g \circ f): A \to C\) is an bijection.

    Proof

    The proof of Part (1) is Exercise (6).

    Part (3) is a direct consequence of the first two parts. We will discuss a process for constructing a proof of Part (2). Using the forward-backward process, we first look at the conclusion of the conditional statement in Part (2). The goal is to prove that \(g \circ f\) is a surjection. Since \((g \circ f): A \to C\), this is equivalent to proving that

    For all \(c \in C\), there exists an \(a \in A\) such that \((g \circ f)(a) = c\).

    Since this statement in the backward process uses a universal quantifier, we will use the choose-an-element method and choose an arbitrary element \(c\) in the set \(C\). The goal now is to find an \(a \in A\) such that \((g \circ f)(a) = c\).

    Now we can look at the hypotheses. In particular, we are assuming that both \(f: A \to B\) and \(g: B \to C\) are surjections. Since we have chosen \(c \in C\), and \(g: B \to C\) is a surjection, we know that

    there exists a \(b \in B\) such that \(g(b) = c\).

    Now, \(b \in B\) and \(f: A \to B\) is a surjection. Hence

    there exists an \(a \in A\) such that \(f(a) = b\).

    If we now compute \((g \circ f)(a)\), we will see that

    \((g \circ f)(a) = g(f(a)) = g(b) = c\).

    We can now write the proof as follows:

    Proof of Theorem 6.20, Part (2)

    Let \(A\), \(B\), and \(C\) be nonempty sets and assume that \(f: A \to B\) and \(g: B \to C\) are both surjections. We will prove that \(g \circ f: A \to C\) is a surjection.

    Let \(c\) be an arbitrary element of \(C\). We will prove there exists an \(a \in A\) such that \((g \circ f)(a) = c\). Since \(g: B \to C\) is a surjection, we conclude that

    there exists a \(b \in B\) such that \(g(b) = c\).

    Now, \(b \in B\) and \(f: A \to B\) is a surjection. Hence

    there exists an \(a \in A\) such that \(f(a) = b\).

    We now see that

    \[\begin{align*} {(g \circ f)(a)} &= & {g(f(a))} \\ {} &= & {g(b)} \\ {} &= & {c.} \end{align*}\]

    We have now shown that for every \(c \in C\), there exists an \(a \in A\) such that \((g \circ f)(a) = c\), and this proves that \(g \circ f\) is a surjection.

    Theorem 6.20 shows us that if \(f\) and \(g\) are both special types of functions, then the composition of \(f\) followed by \(g\) is also that type of function.The next question is, “If the composition of \(f\) followed by \(g\) is an injection (or surjection), can we make any conclusions about \(f\) or \(g\)?” A partial answer to this question is provided in Theorem 6.21. This theorem will be investigated and proved in the Explorations and Activities for this section. See Exercise (10).

    Theorem 6.21

    Let \(A\), \(B\), and \(C\) be nonempty sets and assume that \(f: A \to B\) and \(g: B \to C\).

    1. If \(g \circ f: A \to C\) is an injection, then \(f: A \to B\) is an injection.
    2. If \(g \circ f: A \to C\) is a surjection, then \(f: A \to B\) is a surjection.

    Exercise 6.4

    1. In our definition of the composition of two functions, \(f\) and \(g\), we required that the domain of \(g\) be equal to the codomain of \(f\). However, it is sometimes possible to form the composite function \(g \circ f\) even though dom(\(g\)) \(\ne\) codom(\(f\)). For example, let
      \[\begin{array} {lcl} {f: \mathbb{R} \to \mathbb{R}} &text{ be defined by }& {f(x) = x^2 + 1\text{, and let}} \\ {g: \mathbb{R} - \{0\} \to \mathbb{R}} &text{ be defined by }& {g(x) = \dfrac{1}{x}.} \end{array}\]

      (a) Is it possible to determine \((g \circ f) (x)\) for all \(x \in \mathbb{R}\)? Explain.
      (b) In general, let \(f: A \to T\) and \(g: B \to C\). Find a condition on the domain of \(g\) (other than \(B = T\)) that results in a meaningful definition of the composite function \(g \circ f: A \to C\).
    2. Let \(h: \mathbb{R} \to \mathbb{R}\) be defined \(h(x) = 3x + 2\) and \(g: \mathbb{R} \to \mathbb{R}\) be defined by \(g(x) = x^3\). Determine formulas for the composite functions \(g \circ h\) and \(h \circ g\). Is the function \(g \circ h\) equal to the function \(h \circ g\)? Explain. What does this tell you about the operation of composition of functions?
    3. Following are formulas for certain real functions. Write each of these real functions as the composition of two functions. That is, decompose each of the functions.

      (a) \(F(x) = cos(e^x)\)
      (b) \(G(x) = e^{cos(x)}\)
      (c) \(H(x) = \dfrac{1}{sin x}\)
      (d) \(K(x) = cos(e^{-x^2})\)

    4. The identity function on a set \(S\), denoted by \(I_S\), is defined as follows: \(I_S: S \to S\) by \(I_s(x) = x\) for each \(x \in S\). Let \(f: A \to B\).

      (a) For each \(x \in A\), determine \((f \circ I_A)(x)\) and use this to prove that \(f \circ I_A = f\).
      (b) Prove that \(I_B \circ f = f\).

    5. (a) Let \(f: \mathbb{R} \to \mathbb{R}\) be defined by \(f(x) = x^2\), let \(g: \mathbb{R} \to \mathbb{R}\) be defined by \(g(x) = sin x\), and let \(h: \mathbb{R} \to \mathbb{R}\) be defined by \(h(x) = \sqrt[3]{x}\).

      Determine formulas for \([(h \circ g) \circ f] (x)\) and \([h \circ (g \circ f)](x)\).

      Does this prove that \((h \circ g) \circ f = h \circ (g \circ f)\) for these particular functions? Explain.

      (b) Now let \(A\), \(B\), and \(C\) be sets and let \(f: A \to B\), \(g: B \to C\), and \(h: C \to D\). Prove that \((h \circ g) \circ f = h \circ (g \circ f)\). That is, prove that function composition is an associative operation.

    6. Prove Part (1) of Theorem 6.20.
      Let \(A\), \(B\), and \(C\) be nonempty sets and let \(f: A \to B\) and \(g: B \to C\). If \(f\) and \(g\) are both injections, then \(g \circ f\) is an injection.

    7. For each of the following, give an example of functions \(f: A \to B\) and \(g: B \to C\) that satisfy the stated conditions, or explain why no such example exists.

      (a) The function \(f\) is a surjection, but the function \(g \circ f\) is not a surjection.
      (b) The function \(f\) is an injection, but the function \(g \circ f\) is not an injection.
      (c) The function \(g\) is a surjection, but the function \(g \circ f\) is not a surjection.
      (d) The function \(g\) is an injection, but the function \(g \circ f\) is not an injection.
      (e) The function \(f\) is not a surjection, but the function \(g \circ f\) is a surjection.
      (f) The function \(f\) is not an injection, but the function \(g \circ f\) is an injection.
      (g) The function \(f\) is not an injection, but the function \(g \circ f\) is an injection.
      (h) The function \(g\) is not an injection, but the function \(g \circ f\) is an injection.

    8. Let \(A\) be a nonempty set and let \(f: A \to A\). For each \(n \in \mathbb{N}\), define a funciton \(f^n: A \to A\) recursively as follows: \(f^1 = f\) and for each \(n \in \mathbb{N}\), \(f^{n + 1} = f \circ f^n\). For example, \(f^2 = f \circ f^1 = f \circ f\) and \(f^3 = f \circ f^2 = f \circ (f \circ f)\).

      (a) Let \(f: \mathbb{R} \to \mathbb{R}\) by \(f(x) = x + 1\) for each \(x \in \mathbb{R}\). For each \(n \in \mathbb{N}\) and for each \(x \in \mathbb{R}\), determine a formula for \(f^n(x)\) and use induction to prove that your formula is correct.
      (b) Let \(a, b \in \mathbb{R}\) and let \(f: \mathbb{R} \to \mathbb{R}\) by \(f(x) = ax + b\) for each \(x \in \mathbb{R}\). For each \(n \in \mathbb{N}\) and for each \(x \in \mathbb{R}\), determine a formula for \(f^n(x)\) and use induction to prove that your formula is correct.
      (c) Now let \(A\) be a nonempty set and let \(f: A \to A\). Use induction to prove that for each \(n \in \mathbb{N}\), \(f^{n + 1} = f^n \circ f\). (Note: You will need to use the result in Exercise (5).)

      Explorations and Activities

    9. Exploring Composite Functions. Let \(A\), \(B\), and \(C\) be nonempty sets and let \(f: A \to B\) and \(g: B \to C\). For this activity, it may be useful to draw your arrow diagrams in a triangular arrangement as follows:
      屏幕快照 2019-04-01 下午5.09.57.png
      It might be helpful to consider examples where the sets are small. Try constructing examples where the set \(A\) has 2 elements, the set \(B\) has 3 elements, and the set \(C\) has 2 elements.

      (a) Is it possible to construct an example where \(g \circ f\) is an injection, \(f\) is an injection, but \(g\) is not an injection? Either construct such an example or explain why it is not possible.
      (b) Is it possible to construct an example where \(g \circ f\) is an injection, \(g\) is an injection, but \(f\) is not an injection? Either construct such an example or explain why it is not possible.
      (c) Is it possible to construct an example where \(g \circ f\) is a surjection, \(f\) is a surjection, but \(g\) is not a surjection? Either construct such an example or explain why it is not possible.
      (d) Is it possible to construct an example where \(g \circ f\) is a surjection, \(g\) is a surjection, but \(f\) is not a surjection? Either construct such an example or explain why it is not possible.

    10. The Proof of Theorem 6.21. Use the ideas from Exercise (9) to prove Theorem 6.21. Let \(A\), \(B\) and \(C\) be nonempty sets and let \(f: A \to B\) and \(g: B \to C\).

      (a) If \(g \circ f: A \to C\) is an injection, then \(f: A \to B\) is an injection.
      (b) If \(g \circ f: A \to C\) is a surjection, then \(g: B \to C\) is a surjection.

      Hint: For part (a), start by asking, “What do we have to do to prove that \(f\) is an injection? ” Start with a similar question for part (b).

    Answer

    Add texts here. Do not delete this text first.