Class 12 Maths, Worked in Full Past papersGet updates
Chapter 1 · Relations and Functions

Example 15: Computing g∘fg\circ f on finite sets

ExamplesComposition of functions · Section 1.4
The question

Let f:{2,3,4,5}→{3,4,5,9}f : \{2, 3, 4, 5\} \to \{3, 4, 5, 9\} and g:{3,4,5,9}→{7,11,15}g : \{3, 4, 5, 9\} \to \{7, 11, 15\} be functions defined as f(2)=3f(2) = 3⁠, f(3)=4f(3) = 4⁠, f(4)=f(5)=5f(4) = f(5) = 5 and g(3)=g(4)=7g(3) = g(4) = 7 and g(5)=g(9)=11g(5) = g(9) = 11⁠. Find gofgof⁠.

Exam answer gof(2)=g(f(2))=g(3)=7gof(3)=g(f(3))=g(4)=7gof(4)=g(f(4))=g(5)=11gof(5)=g(f(5))=g(5)=11\begin{aligned} gof(2) &= g(f(2)) = g(3) = 7 \\ gof(3) &= g(f(3)) = g(4) = 7 \\ gof(4) &= g(f(4)) = g(5) = 11 \\ gof(5) &= g(f(5)) = g(5) = 11 \end{aligned}

∴ gof={(2,7),(3,7),\therefore\ gof = \{(2, 7), (3, 7), (4,11),(5,11)}(4, 11), (5, 11)\}⁠.

Want the reason behind every step, the basics and the checks?

The one idea this problem is built on

The composition gofgof (also written g∘fg\circ f⁠) means "first apply ff⁠, then apply gg to the answer": (gof)(x)=g(f(x))(gof)(x) = g(f(x))⁠. It is defined because the set where ff lands, {3,4,5,9}\{3,4,5,9\}⁠, is exactly the set where gg starts. With finite sets there is no formula to simplify: we just follow two arrows for each of the four elements of the domain, one element at a time.

Given, to find, and the plan
Given
A={2,3,4,5}A = \{2,3,4,5\}⁠, B={3,4,5,9}B = \{3,4,5,9\}⁠, C={7,11,15}C = \{7,11,15\}⁠. The function f:A→Bf : A \to B is listed value by value, and so is g:B→Cg : B \to C⁠.
To find
The function gof:A→Cgof : A \to C⁠, that is, its value at each of the four elements 2,3,4,52, 3, 4, 5⁠.
Plan
(1) Check that gofgof makes sense (the codomain of ff equals the domain of gg⁠). (2) For each x∈Ax\in A⁠, read off f(x)f(x)⁠, then read off gg of that value. (3) Collect the four answers and describe the function we get.

Basics you need

1A function on a finite set can be a list

A function f:A→Bf : A \to B assigns to each element of AA exactly one element of BB⁠. When AA is finite, we can define ff completely by listing f(a)f(a) for every a∈Aa\in A⁠. No formula is needed. Basics: what a function is

2Domain and codomain

For f:A→Bf : A \to B⁠, AA is the domain (allowed inputs) and BB is the codomain (where outputs are allowed to land). Not every element of BB has to be used. Basics: sets and ordered pairs

3Composition

If f:A→Bf : A \to B and g:B→Cg : B \to C⁠, then gof:A→Cgof : A \to C is defined by gof(x)=g(f(x))gof(x) = g(f(x)) for every x∈Ax\in A⁠. The function written nearer to xx acts first. Basics: functions

4One-one and onto (for the remarks at the end)

One-one: different inputs give different outputs. Onto: every element of the codomain is an output. Basics: one-one and onto

Solution

  1. Check that gofgof is defined

    ff goes from A={2,3,4,5}A = \{2,3,4,5\} into B={3,4,5,9}B = \{3,4,5,9\}⁠, and gg starts from the same set BB⁠. So every output f(x)f(x) is an element of BB⁠, and gg can be applied to it. Hence gofgof is a function from AA to C={7,11,15}C = \{7,11,15\}⁠:

    A→ f B→ g C,gof:A→C.A \xrightarrow{\ f\ } B \xrightarrow{\ g\ } C, \qquad gof : A \to C.
    ABC2345345971115fg9: no f-arrow arrives15: no g-arrow arrives
    Blue arrows are ff⁠, gold arrows are gg⁠. To find gof(x)gof(x)⁠, start at xx on the left and follow one blue arrow and then one gold arrow. The element 9 of BB and the element 15 of CC are never reached.
    Composition only makes sense when the second function can accept every output of the first. If ff could produce a value outside the domain of gg⁠, then g(f(x))g(f(x)) would have no meaning for that xx⁠. Here ff's codomain and gg's domain are the same set, so there is nothing to worry about. This is exactly the setting of Definition 8.
    Definition 8: for f:A→Bf : A \to B and g:B→Cg : B \to C⁠, gof:A→Cgof : A \to C is given by gof(x)=g(f(x))gof(x) = g(f(x)) for all x∈Ax\in A⁠. Lesson: composition of functions
  2. Compute gof(2)gof(2) and gof(3)gof(3)

    Work from the inside out: first the inner value f(x)f(x)⁠, then gg of it.

    gof(2)=g(f(2))=g(3)=7,gof(3)=g(f(3))=g(4)=7.\begin{aligned} gof(2) &= g(f(2)) = g(3) = 7,\\ gof(3) &= g(f(3)) = g(4) = 7. \end{aligned}
    The bracket g(f(2))g(f(2)) tells us the order. We cannot evaluate gg until we know what it is being applied to, and that is f(2)f(2)⁠. From the list, f(2)=3f(2) = 3⁠; then from gg's list, g(3)=7g(3) = 7⁠. The same two look-ups give f(3)=4f(3) = 4 and g(4)=7g(4) = 7⁠.
    Inner function first: in g(f(x))g(f(x))⁠, ff acts on xx and gg acts on the result. This is the usual rule for nested brackets, the same as working out (2+7)\sqrt{(2+7)} by adding first.
  3. Compute gof(4)gof(4) and gof(5)gof(5)

    gof(4)=g(f(4))=g(5)=11,gof(5)=g(f(5))=g(5)=11.\begin{aligned} gof(4) &= g(f(4)) = g(5) = 11,\\ gof(5) &= g(f(5)) = g(5) = 11. \end{aligned}

    (The textbook shortens the last line to gof(5)=g(5)=11gof(5) = g(5) = 11⁠, because f(5)=5f(5) = 5⁠.)

    The question gives f(4)=f(5)=5f(4) = f(5) = 5⁠: two inputs share the output 5. Whatever gg does to 5, it does once, so gof(4)gof(4) and gof(5)gof(5) must be equal. Note that the value g(9)=11g(9) = 11 is never used, because no element of AA is sent to 9 by ff⁠.
    A function may send different inputs to the same output (here f(4)=f(5)f(4)=f(5)⁠). It may not send one input to two outputs. That is why f(5)f(5) has the single value 5 and the look-up is unambiguous. Basics: what a function is
  4. Collect the answer

    Putting the four values together:

    xx2345
    f(x)f(x)3455
    gof(x)=g(f(x))gof(x) = g(f(x))771111

    So gof(2)=7gof(2) = 7⁠, gof(3)=7gof(3) = 7⁠, gof(4)=11gof(4) = 11⁠, gof(5)=11gof(5) = 11. As a set of ordered pairs,

    gof={(2,7), (3,7), (4,11), (5,11)}.gof = \{(2,7),\ (3,7),\ (4,11),\ (5,11)\}.
    AC234571115gof
    The same information as a single function from AA to CC⁠: the middle set BB has disappeared. Each green arrow is a blue arrow followed by a gold arrow from the previous figure.
    A function on a finite set is completely known once its value at every element of the domain is known (Basic 1). We have all four values, so gofgof has been found in full. The middle set BB is only a stopping point; it does not appear in the answer.
    A function h:A→Ch : A \to C can be written as the set of pairs {(x,h(x)):x∈A}\{(x, h(x)) : x\in A\}⁠. Basics: ordered pairs
  5. What kind of function is gofgof⁠? (an extra look)

    The book does not ask this, but it is worth seeing what the composite inherits.

    • gofgof is not one-one: gof(2)=gof(3)=7gof(2) = gof(3) = 7 with 2≠32 \ne 3⁠.
    • gofgof is not onto CC⁠: the range of gofgof is {7,11}\{7, 11\}⁠, and 15∈C15 \in C is not an output.
    • Neither is ff one-one (f(4)=f(5)f(4)=f(5)⁠) or onto BB (nothing goes to 9), and gg is neither one-one (g(3)=g(4)g(3)=g(4)⁠) nor onto CC (nothing goes to 15).

    Also, the other order fogfog is not defined here: gg outputs 7 or 11, and these are not in the domain {2,3,4,5}\{2,3,4,5\} of ff⁠, so f(g(3))=f(7)f(g(3)) = f(7) has no meaning.

    Each claim is settled by the lists themselves. "Not one-one" needs one pair of different inputs with equal outputs, and 2,32, 3 is such a pair. "Not onto" needs one element of the codomain that is never hit; since gofgof only ever produces 7 and 11, the element 15 is never hit. The remark about fogfog shows that composition depends on order: one order can be defined while the other is not.
    To disprove "one-one" or "onto", one explicit counterexample is enough. Basics: proving and disproving
Result

gof:{2,3,4,5}→{7,11,15}gof : \{2,3,4,5\} \to \{7,11,15\} is given by gof(2)=7,gof(3)=7,gof(4)=11,gof(5)=11,\begin{gathered} gof(2) = 7,\quad gof(3) = 7,\\ gof(4) = 11,\quad gof(5) = 11,\end{gathered} that is, gof={(2,7), (3,7), (4,11), (5,11)}.gof = \{(2,7),\ (3,7),\ (4,11),\ (5,11)\}. This agrees with the textbook's solution.

Check it with numbers

Count the two-step paths in the first figure. From 2: 2→3→72 \to 3 \to 7⁠. From 3: 3→4→73 \to 4 \to 7⁠. From 4: 4→5→114 \to 5 \to 11⁠. From 5: 5→5→115 \to 5 \to 11⁠. There are exactly four paths, one from each element of AA⁠, and they end at 7,7,11,117, 7, 11, 11⁠. The verification script also rebuilds ff and gg as dictionaries and composes them by computer, getting the same four pairs.

Common mistakes
  1. Applying the functions in the wrong order. gof(x)gof(x) means g(f(x))g(f(x))⁠: ff first. Computing f(g(x))f(g(x)) instead fails at once here, since g(2)g(2) is not even defined (2 is not in the domain of gg⁠).
  2. Using g(9)g(9) somewhere. No element of AA is sent to 9, so g(9)=11g(9) = 11 plays no part in gofgof⁠.
  3. Thinking gof(4)≠gof(5)gof(4) \ne gof(5) because 4≠54 \ne 5⁠. Once ff has merged 4 and 5 into the same value, no later function can separate them.
  4. Giving CC as the "answer". The question asks for the function gofgof⁠, which means its value at every element of the domain, not just its codomain or range.
What to take away
  1. gof(x)=g(f(x))gof(x) = g(f(x))⁠: work from the inside out, one element at a time.
  2. gofgof needs the outputs of ff to be acceptable inputs for gg⁠. The reverse composite fogfog may not exist at all.
  3. If ff sends two inputs to the same place, gofgof does too. If gg misses an element of CC⁠, so does gofgof⁠. Composition can never undo a merge or fill a gap left by the last function.

Every fact used, and where it comes from

FactUsed inSource
Definition of composition gof(x)=g(f(x))gof(x) = g(f(x))Steps 1–4Definition 8, Section 1.4 (Lesson: composition)
The values of ff and ggSteps 2–4Given in the question
A function is determined by its values on the domainStep 4Meaning of a function (Basics: what a function is)
Definitions of one-one and ontoStep 5Definitions 5 and 6, Section 1.3 (Lesson: types of functions)
All four values and the claims in Step 5Result, CheckRecomputed by brute force in the site's verification script
Found an error, or want more?

Tell us if something on this page is wrong or unclear, or if you would like a fuller explanation, another method or a new feature. Send feedback on this problem →