• Foundation
  • About 16 min
  • 5 practice questions

Composition of functions

Form gof and fog from two functions, check when a composition is defined, and use the fact that composition is associative but not commutative.

If something looks wrong, please tell us.

By the end of this lesson you can

  • Define gof and evaluate it for a function given as a table or a formula.
  • Show by a single value that gof and fog are usually different.
  • Use the properties of composition with one-one and onto functions.

Many processes run in stages: a price is discounted, then tax is added; a temperature is converted, then rounded. Joining two functions so that the output of the first becomes the input of the second is called composition, and it is the language we need for inverses in the next lesson and for the chain rule in Chapter 5.

Definition

Let f : A → B and g : B → C. The composition of f and g is the function gof : A → C given by (gof)(x) = g(f(x)) for every x ∈ A. Read gof as 'g after f': apply f first, then g. It is defined only when every output of f lies in the domain of g (range of f ⊆ domain of g).

(gof)(x) = g(f(x)): first f, then g. In general gof ≠ fog.

— Composition

How gof works on an input x

  1. Start with x in A x must be in the domain of f.
  2. Apply f Get f(x), which lies in B.
  3. Apply g to f(x) B must be inside the domain of g.
  4. Output g(f(x)) in C This is (gof)(x).

Worked example 1: functions given by tables

Let f : {1, 2, 3, 4} → {2, 5, 8, 11} with f(1) = 5, f(2) = 2, f(3) = 11, f(4) = 5, and g : {2, 5, 8, 11} → {0, 1} with g(2) = 0, g(5) = 1, g(8) = 1, g(11) = 0. Working: (gof)(1) = g(5) = 1; (gof)(2) = g(2) = 0; (gof)(3) = g(11) = 0; (gof)(4) = g(5) = 1. So gof = {(1, 1), (2, 0), (3, 0), (4, 1)}. Here fog is not defined at all: g can output 0, and 0 is not in the domain {1, 2, 3, 4} of f, so f cannot act on every output of g.

Worked example 2: gof and fog differ

Let f, g : R → R with f(x) = 2x + 1 and g(x) = x². Working: (gof)(x) = g(2x + 1) = (2x + 1)² = 4x² + 4x + 1. (fog)(x) = f(x²) = 2x² + 1. At x = 1: (gof)(1) = 9 but (fog)(1) = 3. One value is enough to show gof ≠ fog, so composition is not commutative.

Worked example 3: a function that undoes itself

Let f(x) = x/(x − 1) for real x ≠ 1 (its values are never 1, so f maps R − {1} to itself). Find fof. Working: (fof)(x) = f(x/(x − 1)) = [x/(x − 1)] ÷ [x/(x − 1) − 1]. The denominator is [x − (x − 1)]/(x − 1) = 1/(x − 1). So (fof)(x) = [x/(x − 1)] × (x − 1) = x. Applying f twice returns the input: fof is the identity function.

Worked example 4: modulus and a shift

Let f(x) = |x| and g(x) = x − 3 on R. Then (gof)(x) = |x| − 3 and (fog)(x) = |x − 3|. At x = 0: (gof)(0) = −3 while (fog)(0) = 3. Note also that gof can take negative values, while fog never does.

Properties of composition

Facts used in proofs
PropertyStatement
Not commutativegof and fog are usually different, and one may exist without the other
Associativeho(gof) = (hog)of whenever the compositions are defined
IdentityfoI_A = f and I_Bof = f for f : A → B, where I is the identity function
One-oneIf f and g are both one-one, gof is one-one
OntoIf f : A → B and g : B → C are both onto, gof is onto

Proof of the one-one property: suppose (gof)(x₁) = (gof)(x₂), i.e. g(f(x₁)) = g(f(x₂)). Since g is one-one, f(x₁) = f(x₂); since f is one-one, x₁ = x₂. So gof is one-one. Proof of the onto property: take any z ∈ C. As g is onto, z = g(y) for some y ∈ B; as f is onto, y = f(x) for some x ∈ A. Then (gof)(x) = g(y) = z.

Key takeaways: gof means 'do f, then g', and needs the outputs of f to be valid inputs for g. Composition is associative but not commutative, so always keep the order. Composing one-one functions gives a one-one function, and composing onto functions gives an onto function.

Check your understanding

  1. 1. If f(x) = x + 3 and g(x) = 2x on R, what is (gof)(4)?

    1. 11
    2. 10
    3. 14
    4. 7
    Show answer

    Answer: C. (gof)(4) = g(f(4)) = g(7) = 2 × 7 = 14. The value 11 is (fog)(4) = f(8) = 11, which uses the opposite order.

  2. 2. For f(x) = x² and g(x) = x − 1 on R, which expression equals (fog)(x)?

    1. x² − 1
    2. x² − 2x + 1
    3. x² + 1
    4. x − 1
    Show answer

    Answer: B. (fog)(x) = f(g(x)) = f(x − 1) = (x − 1)² = x² − 2x + 1. x² − 1 is (gof)(x) = g(x²).

  3. 3. f(x) = 3x − 2 and g(x) = (x + 2)/3 on R. What is (gof)(x)?

    1. x
    2. x − 2
    3. 3x
    4. (3x + 4)/3
    Show answer

    Answer: A. (gof)(x) = g(3x − 2) = (3x − 2 + 2)/3 = 3x/3 = x. So gof is the identity; g undoes f.

  4. 4. Assertion (A): For f(x) = x + 1 and g(x) = 2x on R, gof ≠ fog.
    Reason (R): Composition of functions is associative.

    1. Both A and R are true, and R is the correct explanation of A
    2. Both A and R are true, but R is not the correct explanation of A
    3. A is true but R is false
    4. A is false but R is true
    Show answer

    Answer: B. A is true: (gof)(x) = 2x + 2 but (fog)(x) = 2x + 1, which differ at every x. R is also true (ho(gof) = (hog)of), but associativity is about grouping three functions, not about changing the order of two, so it does not explain A.

  5. 5. f : A → B is onto but not one-one, and g : B → C is a bijection. What can be said about gof : A → C?

    1. gof is one-one and onto
    2. gof is one-one but not onto
    3. gof is neither one-one nor onto
    4. gof is onto but not one-one
    Show answer

    Answer: D. Onto: both f and g are onto, so gof is onto. Not one-one: f(x₁) = f(x₂) for some x₁ ≠ x₂, so g(f(x₁)) = g(f(x₂)) too; gof also sends two different inputs to the same output.

Privacy · Terms · Refunds · Delivery